dbServices

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2022 License: MIT Imports: 29 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ERROR_CODE_VALIDATION_REQUIRED = "required"
	ERROR_CODE_VALIDATION_EMAIL    = "notValidEmail"
	ERROR_CODE_VALIDATION          = "validationFailed"

	ERROR_CODE_TRANSACTION_NOT_PRESENT       = "transactionNotPresent"
	ERROR_CODE_TRANSACTION_RECORD_NOT_EXISTS = "transactionNoRecordExists"

	VALIDATION_TYPE_EMAIL = "email"

	SCHEMA_ID_FIELD = "Id"
)
View Source
const (

	//Driver Types
	DATABASE_DRIVER_BOLTDB  = "boltDB"
	DATABASE_DRIVER_MONGODB = "mongoDB"
)

Variables

View Source
var BoltDB *storm.DB
View Source
var DB *sql.DB
View Source
var DBMutex *sync.RWMutex
View Source
var MongoDB *mgo.Database
View Source
var MongoSession *mgo.Session

Functions

func GetDBIndexes

func GetDBIndexes(x interface{}) map[string]string

GetIndexes provides a way to reflect on your structure to get structs tagged with `dbIndex`. This function is used to generate Indexes for MongoDB and other databases.

func GetReflectionFieldValue

func GetReflectionFieldValue(key string, x interface{}) string

func GetStructReflectionValue

func GetStructReflectionValue(key string, val reflect.Value) string

func GetValidationTags

func GetValidationTags(x interface{}) map[string]string

GetValidationTags provides a way to reflect on your structure to get structs tagged with `dbIndex`. This function is used to generate Indexes for MongoDB and other databases.

func Initialize

func Initialize() error

func OverrideMongoDBConnection

func OverrideMongoDBConnection(connectionString string, dbName string)

func ReadMongoDB

func ReadMongoDB() (mdb *mgo.Database)

func RunDBCreate

func RunDBCreate()

func SetFieldValue

func SetFieldValue(key string, val reflect.Value, value interface{})

Types

type CacheKey

type CacheKey struct {
	// contains filtered or unexported fields
}

CacheKey is the key lookup for the collectionCache

type CacheValue

type CacheValue struct {
	// contains filtered or unexported fields
}

CacheValue is the value for the collectionCache

type CollectionCache

type CollectionCache struct {
}

CollectionCache provides DB object Caching functions.

func (CollectionCache) Count

func (cc CollectionCache) Count() (value int)

Count returns the length of the cache.

func (CollectionCache) DeleteAll added in v1.1.1

func (cc CollectionCache) DeleteAll()

DeleteAll deletes the whole collection cache

func (CollectionCache) Fetch

func (cc CollectionCache) Fetch(collection string, id string, value interface{}) (ok bool)

Fetch will get the collection entity

func (CollectionCache) Remove

func (cc CollectionCache) Remove(collection string, id string)

Remove will remove from the collection cache.

func (CollectionCache) Store

func (cc CollectionCache) Store(collection string, id string, value interface{})

Store will store the collection object.

type FieldType

type FieldType struct {
	IsArray bool
	Value   string
}

type FieldValidation

type FieldValidation struct {
	Required  bool   `json:"required"`
	Type      string `json:"type"`
	Min       string `json:"min"`
	Max       string `json:"max"`
	Length    string `json:"length"`
	LengthMax string `json:"lengthMax"`
	LengthMin string `json:"lengthMin"`
}

type Mongo_Replica_Member

type Mongo_Replica_Member struct {
	Id          int    `bson:"_id"`
	Host        string `bson:"host"`
	ArbiterOnly bool   `bson:"arbiterOnly"`
	Hidden      bool   `bson:"hidden"`
	Priority    int    `bson:"priority"`
	Votes       int    `bson:"votes"`
	SlaveDelay  int    `bson:"slaveDelay"`
}

type Mongo_Replica_Setting

type Mongo_Replica_Setting struct {
	ChainingAllowed      bool `bson:"chainingAllowed"`
	HeartbeatTimeoutSecs int  `bson:"heartbeatTimeoutSecs"`
}

type Mongo_Result_Repl_Conf

type Mongo_Result_Repl_Conf struct {
	Config struct {
		Id       string                 `bson:"_id"`
		Version  int                    `bson:"version"`
		Members  []Mongo_Replica_Member `bson:"members"`
		Settings Mongo_Replica_Setting  `bson:"settings"`
	} `bson:"config"`
}

type NOSQLCollection

type NOSQLCollection struct {
	Name       string      `json:"name"`
	ClearTable bool        `json:"clearTable"`
	Schema     NOSQLSchema `json:"schema"`
	FieldTypes map[string]FieldType
}

type NOSQLSchema

type NOSQLSchema struct {
	Name   string             `json:"name"`
	Fields []NOSQLSchemaField `json"fields"`
}

type NOSQLSchemaDB

type NOSQLSchemaDB struct {
	Collections []NOSQLCollection `json:"collections"`
}

type NOSQLSchemaField

type NOSQLSchemaField struct {
	Name         string           `json:"name"`
	Type         string           `json:"type"`
	Index        string           `json:"index"`
	View         bool             `json:"view"`
	Ref          string           `json:"ref"`
	Format       string           `json:"format"`
	OmitEmpty    bool             `json:"omitEmpty"`
	DefaultValue string           `json:"defaultValue"`
	Required     bool             `json:"required"`
	Schema       NOSQLSchema      `json:"schema"`
	Validation   *FieldValidation `json:"validate, omitempty"`
	Join         join             `json:"join"`
	NoPersist    bool             `json:"noPersist"`
}

type SchemaNameSorter

type SchemaNameSorter []NOSQLCollection

AxisSorter sorts planets by axis.

func (SchemaNameSorter) Len

func (a SchemaNameSorter) Len() int

func (SchemaNameSorter) Less

func (a SchemaNameSorter) Less(i, j int) bool

func (SchemaNameSorter) Swap

func (a SchemaNameSorter) Swap(i, j int)

Directories

Path Synopsis
bolt
common
example module
mongo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL