gg_dbal_drivers

package
v0.3.31 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const KeyFieldName = "_key" // all entities should have this field
View Source
const NameArango = "arango"
View Source
const NameBolt = "bolt"
View Source
const NameMsSQL = "mssql"
View Source
const NameMySQL = "mysql"
View Source
const NameODBC = "odbc"
View Source
const NameOracle = "oracle"

Variables

View Source
var (
	ArangoConst = struct {
		KeyFieldName string
		IndexPersist string
		IndexGeo     string
		IndexGeoJson string
	}{
		KeyFieldName: "_key",
		IndexPersist: "persist",
		IndexGeo:     "geo",
		IndexGeoJson: "geojson",
	}
)

Functions

func BindParams

func BindParams(query string, bindVars map[string]interface{}, earlyReplace bool) (command string, values []interface{})

func IsRecordNotFoundError

func IsRecordNotFoundError(err error) bool

func QueryGetParamNames

func QueryGetParamNames(query string) []string

QueryGetParamNames return unique param names

func QuerySelectParams

func QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

Types

type CacheManager

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

func Cache

func Cache() *CacheManager

Cache return a thread safe cache manager

func NewCache

func NewCache() *CacheManager

func (*CacheManager) Clear

func (instance *CacheManager) Clear()

func (*CacheManager) Close

func (instance *CacheManager) Close()

func (*CacheManager) Create

func (instance *CacheManager) Create(driver, dsn string) (IDatabase, error)

func (*CacheManager) Get

func (instance *CacheManager) Get(driver, dsn string) (IDatabase, error)

Get "driver": "arango", "dsn": "root:1234567890@tcp(localhost:8529)/my-database)"

func (*CacheManager) GetOrCreate

func (instance *CacheManager) GetOrCreate(key, driver, dsn string) (IDatabase, error)

func (*CacheManager) Open

func (instance *CacheManager) Open()

func (*CacheManager) Remove

func (instance *CacheManager) Remove(uid string)

type DriverArango

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

func NewDriverArango

func NewDriverArango(dsn ...interface{}) *DriverArango

func (*DriverArango) Close

func (instance *DriverArango) Close() error

func (*DriverArango) Collection

func (instance *DriverArango) Collection(name string, createIfDoesNotExists bool) (*DriverArangoCollection, error)

func (*DriverArango) Count

func (instance *DriverArango) Count(query string, bindVars map[string]interface{}) (int64, error)

func (*DriverArango) Delete

func (instance *DriverArango) Delete(collectionName string, item interface{}) (map[string]interface{}, error)

func (*DriverArango) Driver

func (instance *DriverArango) Driver() interface{}

func (*DriverArango) DriverName

func (instance *DriverArango) DriverName() string

func (*DriverArango) Enabled

func (instance *DriverArango) Enabled() bool

func (*DriverArango) EnsureCollection

func (instance *DriverArango) EnsureCollection(collection string) (bool, error)

func (*DriverArango) EnsureIndex

func (instance *DriverArango) EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)

func (*DriverArango) Exec

func (instance *DriverArango) Exec(query string, bindVars map[string]interface{}) (interface{}, error)

func (*DriverArango) ExecMultiple

func (instance *DriverArango) ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) ([]interface{}, error)

func (*DriverArango) ExecNative

func (instance *DriverArango) ExecNative(command string, bindVars map[string]interface{}) (interface{}, error)

func (*DriverArango) Exists

func (instance *DriverArango) Exists(collection, key string) (bool, error)

func (*DriverArango) Find

func (instance *DriverArango) Find(collection string, fieldName string, fieldValue interface{}) (interface{}, error)

func (*DriverArango) ForEach

func (instance *DriverArango) ForEach(collectionOrQuery string, callback ForEachCallback) error

func (*DriverArango) Get

func (instance *DriverArango) Get(collection string, key string) (map[string]interface{}, error)

func (*DriverArango) Insert

func (instance *DriverArango) Insert(collectionName string, item map[string]interface{}) (map[string]interface{}, error)

func (*DriverArango) Open

func (instance *DriverArango) Open() error

func (*DriverArango) QueryGetParamNames

func (instance *DriverArango) QueryGetParamNames(query string) []string

func (*DriverArango) QuerySelectParams

func (instance *DriverArango) QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

func (*DriverArango) Remove

func (instance *DriverArango) Remove(collection, key string) error

func (*DriverArango) Uid

func (instance *DriverArango) Uid() string

func (*DriverArango) Update

func (instance *DriverArango) Update(collectionName string, item map[string]interface{}) (map[string]interface{}, error)

func (*DriverArango) Upsert

func (instance *DriverArango) Upsert(collection string, item map[string]interface{}) (map[string]interface{}, error)

type DriverArangoCollection

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

func (*DriverArangoCollection) Count

func (instance *DriverArangoCollection) Count() (int64, error)

func (*DriverArangoCollection) EnsureIndex

func (instance *DriverArangoCollection) EnsureIndex(typeName string, fields []string, unique bool) (bool, error)

func (*DriverArangoCollection) Exists

func (instance *DriverArangoCollection) Exists(key string) (bool, error)

func (*DriverArangoCollection) Name

func (instance *DriverArangoCollection) Name() string

func (*DriverArangoCollection) Read

func (instance *DriverArangoCollection) Read(key string) (map[string]interface{}, driver.DocumentMeta, error)

func (*DriverArangoCollection) Remove

func (instance *DriverArangoCollection) Remove(key string) (driver.DocumentMeta, error)

func (*DriverArangoCollection) RemoveIndex

func (instance *DriverArangoCollection) RemoveIndex(typeName string, fields []string) (bool, error)

func (*DriverArangoCollection) Upsert

func (instance *DriverArangoCollection) Upsert(doc map[string]interface{}) (map[string]interface{}, driver.DocumentMeta, error)

type DriverBolt

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

func NewDriverBolt

func NewDriverBolt(dsn ...interface{}) *DriverBolt

func (*DriverBolt) Close

func (instance *DriverBolt) Close() error

func (*DriverBolt) Driver

func (instance *DriverBolt) Driver() interface{}

func (*DriverBolt) DriverName

func (instance *DriverBolt) DriverName() string

func (*DriverBolt) Enabled

func (instance *DriverBolt) Enabled() bool

func (*DriverBolt) EnsureCollection

func (instance *DriverBolt) EnsureCollection(collection string) (bool, error)

func (*DriverBolt) EnsureIndex

func (instance *DriverBolt) EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)

func (*DriverBolt) ExecMultiple

func (instance *DriverBolt) ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) ([]interface{}, error)

func (*DriverBolt) ExecNative

func (instance *DriverBolt) ExecNative(command string, bindingVars map[string]interface{}) (interface{}, error)

func (*DriverBolt) Find

func (instance *DriverBolt) Find(collection string, fieldName string, fieldValue interface{}) (interface{}, error)

func (*DriverBolt) ForEach

func (instance *DriverBolt) ForEach(collection string, callback ForEachCallback) error

func (*DriverBolt) Get

func (instance *DriverBolt) Get(collection string, key string) (map[string]interface{}, error)

func (*DriverBolt) Open

func (instance *DriverBolt) Open() error

func (*DriverBolt) QueryGetParamNames

func (instance *DriverBolt) QueryGetParamNames(query string) []string

func (*DriverBolt) QuerySelectParams

func (instance *DriverBolt) QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

func (*DriverBolt) Remove

func (instance *DriverBolt) Remove(collection string, key string) error

func (*DriverBolt) Uid

func (instance *DriverBolt) Uid() string

func (*DriverBolt) Upsert

func (instance *DriverBolt) Upsert(collection string, doc map[string]interface{}) (map[string]interface{}, error)

type DriverGorm

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

func NewDriverGorm

func NewDriverGorm(driver string, dsn ...interface{}) *DriverGorm

NewDriverGorm "admin:admin@tcp(localhost:3306)/test"

func (*DriverGorm) AutomigrateModelSchema

func (instance *DriverGorm) AutomigrateModelSchema(models ...interface{}) (err error)

func (*DriverGorm) AutomigrateSchema

func (instance *DriverGorm) AutomigrateSchema(schema *dbschema.DbSchema) (err error)

func (*DriverGorm) AutomigrateSchemaFromfile

func (instance *DriverGorm) AutomigrateSchemaFromfile(filename string) (err error)

func (*DriverGorm) Close

func (instance *DriverGorm) Close() (err error)

func (*DriverGorm) Driver

func (instance *DriverGorm) Driver() interface{}

func (*DriverGorm) DriverName

func (instance *DriverGorm) DriverName() string

func (*DriverGorm) Enabled

func (instance *DriverGorm) Enabled() bool

func (*DriverGorm) EnsureCollection

func (instance *DriverGorm) EnsureCollection(collection string) (bool, error)

func (*DriverGorm) EnsureIndex

func (instance *DriverGorm) EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)

func (*DriverGorm) ExecMultiple

func (instance *DriverGorm) ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) (response []interface{}, err error)

func (*DriverGorm) ExecNative

func (instance *DriverGorm) ExecNative(command string, bindVars map[string]interface{}) (result interface{}, err error)

func (*DriverGorm) Exists

func (instance *DriverGorm) Exists(collection, key string) (bool, interface{})

func (*DriverGorm) Find

func (instance *DriverGorm) Find(collection string, fieldName string, fieldValue interface{}) (response interface{}, err error)

func (*DriverGorm) ForEach

func (instance *DriverGorm) ForEach(collection string, callback ForEachCallback) error

func (*DriverGorm) Get

func (instance *DriverGorm) Get(collection string, key string) (response map[string]interface{}, err error)

func (*DriverGorm) GetDB

func (instance *DriverGorm) GetDB() (response *gorm.DB, err error)

func (*DriverGorm) GetDriver

func (instance *DriverGorm) GetDriver() (response string)

func (*DriverGorm) GetMode

func (instance *DriverGorm) GetMode() string

func (*DriverGorm) GetSchema

func (instance *DriverGorm) GetSchema() (schema *dbschema.DbSchema, err error)

func (*DriverGorm) Open

func (instance *DriverGorm) Open() error

func (*DriverGorm) QueryGetParamNames

func (instance *DriverGorm) QueryGetParamNames(query string) []string

func (*DriverGorm) QuerySelectParams

func (instance *DriverGorm) QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

func (*DriverGorm) Remove

func (instance *DriverGorm) Remove(collection, key string) (err error)

func (*DriverGorm) SaveSchemaToFile

func (instance *DriverGorm) SaveSchemaToFile(filename string) (err error)

func (*DriverGorm) SetDriver

func (instance *DriverGorm) SetDriver(value string) *DriverGorm

func (*DriverGorm) SetMode

func (instance *DriverGorm) SetMode(value string) *DriverGorm

func (*DriverGorm) Uid

func (instance *DriverGorm) Uid() string

func (*DriverGorm) Upsert

func (instance *DriverGorm) Upsert(collection string, item map[string]interface{}) (response map[string]interface{}, err error)

type DriverODBC

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

func (*DriverODBC) Close

func (instance *DriverODBC) Close() error

func (*DriverODBC) Driver

func (instance *DriverODBC) Driver() interface{}

func (*DriverODBC) DriverName

func (instance *DriverODBC) DriverName() string

func (*DriverODBC) Enabled

func (instance *DriverODBC) Enabled() bool

func (*DriverODBC) EnsureCollection

func (instance *DriverODBC) EnsureCollection(collection string) (bool, error)

func (*DriverODBC) EnsureIndex

func (instance *DriverODBC) EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)

func (*DriverODBC) ExecMultiple

func (instance *DriverODBC) ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) (response []interface{}, err error)

func (*DriverODBC) ExecNative

func (instance *DriverODBC) ExecNative(command string, bindVars map[string]interface{}) (interface{}, error)

func (*DriverODBC) Find

func (instance *DriverODBC) Find(collection string, fieldName string, fieldValue interface{}) (interface{}, error)

func (*DriverODBC) ForEach

func (instance *DriverODBC) ForEach(collection string, callback ForEachCallback) error

func (*DriverODBC) Get

func (instance *DriverODBC) Get(collection string, key string) (map[string]interface{}, error)

func (*DriverODBC) Open

func (instance *DriverODBC) Open() error

func (*DriverODBC) QueryGetParamNames

func (instance *DriverODBC) QueryGetParamNames(query string) []string

func (*DriverODBC) QuerySelectParams

func (instance *DriverODBC) QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

func (*DriverODBC) Remove

func (instance *DriverODBC) Remove(collection, key string) error

func (*DriverODBC) Uid

func (instance *DriverODBC) Uid() string

func (*DriverODBC) Upsert

func (instance *DriverODBC) Upsert(collection string, item map[string]interface{}) (map[string]interface{}, error)

type DriverSQL

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

func NewDriverODBC

func NewDriverODBC(driver string, dsn ...interface{}) *DriverSQL

NewDriverODBC ODBC: "driver=mysql;server=%s;database=%s;user=%s;password=%s;" MSSQL: "server=%s;database=%s;uid=%s;pwd=%s;port=%s;TDS_Version=8.0"

func NewDriverSQL

func NewDriverSQL(driver string, dsn ...interface{}) *DriverSQL

NewDriverSQL "admin:admin@tcp(localhost:3306)/test"

func (*DriverSQL) Close

func (instance *DriverSQL) Close() error

func (*DriverSQL) Driver

func (instance *DriverSQL) Driver() interface{}

func (*DriverSQL) DriverName

func (instance *DriverSQL) DriverName() string

func (*DriverSQL) Enabled

func (instance *DriverSQL) Enabled() bool

func (*DriverSQL) EnsureCollection

func (instance *DriverSQL) EnsureCollection(collection string) (bool, error)

func (*DriverSQL) EnsureIndex

func (instance *DriverSQL) EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)

func (*DriverSQL) ExecMultiple

func (instance *DriverSQL) ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) (response []interface{}, err error)

func (*DriverSQL) ExecNative

func (instance *DriverSQL) ExecNative(command string, bindVars map[string]interface{}) (interface{}, error)

func (*DriverSQL) Find

func (instance *DriverSQL) Find(collection string, fieldName string, fieldValue interface{}) (interface{}, error)

func (*DriverSQL) ForEach

func (instance *DriverSQL) ForEach(collection string, callback ForEachCallback) error

func (*DriverSQL) Get

func (instance *DriverSQL) Get(collection string, key string) (map[string]interface{}, error)

func (*DriverSQL) Open

func (instance *DriverSQL) Open() error

func (*DriverSQL) QueryGetParamNames

func (instance *DriverSQL) QueryGetParamNames(query string) []string

func (*DriverSQL) QuerySelectParams

func (instance *DriverSQL) QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}

func (*DriverSQL) Remove

func (instance *DriverSQL) Remove(collection, key string) error

func (*DriverSQL) Uid

func (instance *DriverSQL) Uid() string

func (*DriverSQL) Upsert

func (instance *DriverSQL) Upsert(collection string, item map[string]interface{}) (map[string]interface{}, error)

type ForEachCallback

type ForEachCallback func(map[string]interface{}) bool // if return TRUE, exit loop

type IDatabase

type IDatabase interface {
	Uid() string
	DriverName() string
	Driver() interface{}
	Enabled() bool
	Open() error
	Close() error

	Upsert(collection string, doc map[string]interface{}) (map[string]interface{}, error)
	Remove(collection string, key string) error
	Get(collection string, key string) (map[string]interface{}, error)
	ForEach(collection string, callback ForEachCallback) error
	Find(collection string, fieldName string, fieldValue interface{}) (interface{}, error)

	// optional methods. May be not supported from all databases
	EnsureIndex(collection string, typeName string, fields []string, unique bool) (bool, error)
	EnsureCollection(collection string) (bool, error)

	// native methods does not support cross-database
	ExecNative(command string, bindingVars map[string]interface{}) (interface{}, error)
	ExecMultiple(commands []string, bindVars []map[string]interface{}, options interface{}) ([]interface{}, error)

	// utils
	QueryGetParamNames(query string) []string
	QuerySelectParams(query string, allParams map[string]interface{}) map[string]interface{}
}

func NewDatabase

func NewDatabase(driverName, connectionString string) (driver IDatabase, err error)

func NewDatabaseFromDsn

func NewDatabaseFromDsn(driverName string, dsn *gg_dbal_commons.Dsn) (driver IDatabase, err error)

func OpenDatabase

func OpenDatabase(driver, connectionString string) (IDatabase, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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