Documentation ¶
Overview ¶
Package dbServices provides a set of extensions for database utilities and ORM generation
Index ¶
- Constants
- Variables
- func GetDBIndexes(x interface{}) map[string]string
- func GetMongoDialInfo() (*mgo.DialInfo, error)
- func GetReflectionFieldValue(key string, x interface{}) string
- func GetStructReflectionValue(key string, val reflect.Value) string
- func GetValidationTags(x interface{}) map[string]string
- func Initialize()
- func OverrideMongoDBConnection(connectionString string, dbName string)
- func ReadMongoDB() (mdb *mgo.Database)
- func RunDBCreate()
- func SetFieldValue(key string, val reflect.Value, value interface{})
- type CacheKey
- type CacheValue
- type CollectionCache
- func (cc CollectionCache) Count() (value int)
- func (cc CollectionCache) DeleteAll()
- func (cc CollectionCache) Fetch(collection string, id string, value interface{}) (ok bool)
- func (cc CollectionCache) Remove(collection string, id string)
- func (cc CollectionCache) Store(collection string, id string, value interface{})
- type FieldType
- type FieldValidation
- type Mongo_Replica_Member
- type Mongo_Replica_Setting
- type Mongo_Result_Repl_Conf
- type NOSQLCollection
- type NOSQLSchema
- type NOSQLSchemaDB
- type NOSQLSchemaField
- type SchemaNameSorter
Constants ¶
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" )
const ( //Driver Types DATABASE_DRIVER_BOLTDB = "boltDB" DATABASE_DRIVER_MONGODB = "mongoDB" )
Variables ¶
var BoltDB *storm.DB
BoltDB is the global bolt database connection
var DBMutex *sync.RWMutex
DBMutex is a mutex for the database connection
var MongoDB *mgo.Database
MongoDB is the global mongo database connection
var MongoSession *mgo.Session
MongoSession is the global mongo session
Functions ¶
func GetDBIndexes ¶
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 GetMongoDialInfo ¶
GetMongoDialInfo returns a mgo.DialInfo object based on the current serverSettings
func GetReflectionFieldValue ¶
func GetValidationTags ¶
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 OverrideMongoDBConnection ¶
OverrideMongoDBConnection allows you to override the connection string for the mongo database
func ReadMongoDB ¶
ReadMongoDB will read the database connection from memory
func RunDBCreate ¶
func RunDBCreate()
func SetFieldValue ¶
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 ¶
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 FieldValidation ¶
type Mongo_Replica_Member ¶
type Mongo_Replica_Setting ¶
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"` 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)