dbServices

package module
v0.0.0-...-a499989 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 27 Imported by: 4

Documentation

Overview

Package dbServices provides a set of extensions for database utilities and ORM generation

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

BoltDB is the global bolt database connection

View Source
var DBMutex *sync.RWMutex

DBMutex is a mutex for the database connection

View Source
var MongoDB *mgo.Database

MongoDB is the global mongo database connection

View Source
var MongoSession *mgo.Session

MongoSession is the global mongo 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 GetMongoDialInfo

func GetMongoDialInfo() (*mgo.DialInfo, error)

GetMongoDialInfo returns a mgo.DialInfo object based on the current serverSettings

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()

Initialize will initialize the database connection

func OverrideMongoDBConnection

func OverrideMongoDBConnection(connectionString string, dbName string)

OverrideMongoDBConnection allows you to override the connection string for the mongo database

func ReadMongoDB

func ReadMongoDB() (mdb *mgo.Database)

ReadMongoDB will read the database connection from memory

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

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"`
	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
stubs Module
common
stubs Module
example module
mongo
stubs Module

Jump to

Keyboard shortcuts

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