coredb

package
v0.0.0-...-ff5c026 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseQueryBuilder

func BaseQueryBuilder(filter map[string]interface{}, tableName, tableColumns string, sqlMatcher string) sq.SelectBuilder

func GetStructColumns

func GetStructColumns(someStruct interface{}) string

func GetStructTags

func GetStructTags(model interface{}) map[string]string

func ListSelectStatement

func ListSelectStatement(baseStmt sq.SelectBuilder, orderBy string, limit int64, cursor *int64, cursorName string) (string, []interface{}, error)

func MarshalPretty

func MarshalPretty(any interface{}) ([]byte, error)

func MarshalToBytes

func MarshalToBytes(any interface{}) ([]byte, error)

func ToSnakeCase

func ToSnakeCase(s string) string

func UnmarshalToMap

func UnmarshalToMap(b []byte) (map[string]interface{}, error)

Types

type AllDBService

type AllDBService struct {
	RegisteredDBs []*CoreDB
	*coreRpc.UnimplementedDbAdminServiceServer
}

func NewAllDBService

func NewAllDBService() *AllDBService

func (*AllDBService) Backup

func (*AllDBService) FindCoreDB

func (a *AllDBService) FindCoreDB(name string) *CoreDB

func (*AllDBService) ListBackup

func (*AllDBService) RegisterCoreDB

func (a *AllDBService) RegisterCoreDB(cdb *CoreDB)

func (*AllDBService) Restore

type CoreDB

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

CoreDB is the exported struct

func NewCoreDB

func NewCoreDB(l log.Logger, cfg *commonCfg.Config, cronFuncs map[string]func()) (*CoreDB, error)

NewCoreDB facilitates creation of (wrapped) genji database alongside badger DB engine if one wants to use one or the other. or if internally will use the underlying badger DB engine to create Stream for example for backup, restore, or anything

func (*CoreDB) BulkExec

func (c *CoreDB) BulkExec(stmtMap map[string][]interface{}) error

func (*CoreDB) Exec

func (c *CoreDB) Exec(stmt string, args ...interface{}) error

func (*CoreDB) MakeSchema

func (c *CoreDB) MakeSchema() error

func (*CoreDB) Query

func (c *CoreDB) Query(stmt string, args ...interface{}) (*QueryResult, error)

func (*CoreDB) QueryOne

func (c *CoreDB) QueryOne(stmt string, args ...interface{}) (*DocumentResult, error)

func (*CoreDB) RegisterCronFunction

func (c *CoreDB) RegisterCronFunction(funcSpec string, function func()) error

func (*CoreDB) RegisterModels

func (c *CoreDB) RegisterModels(modelsMap map[string]DbModel) error

Register dao models for db

func (*CoreDB) SingleListBackup

func (c *CoreDB) SingleListBackup(ctx context.Context, in *emptypb.Empty) ([]*coreRpc.SingleBackupResult, error)

type DbModel

type DbModel interface {
	CreateSQL() []string
}

DbModel Basic table model interface,

type DocumentResult

type DocumentResult struct {
	Doc document.Document
}

func (*DocumentResult) StructScan

func (d *DocumentResult) StructScan(dest interface{}) error

type Error

type Error struct {
	Reason ErrorReason
	Err    error
}

func (Error) Error

func (err Error) Error() string

type ErrorReason

type ErrorReason int

type QueryParams

type QueryParams struct {
	Params map[string]interface{}
}

func AnyToQueryParam

func AnyToQueryParam(m interface{}, snakeCase bool) (res QueryParams, err error)

func (*QueryParams) ColumnsAndValues

func (qp *QueryParams) ColumnsAndValues() ([]string, []interface{})

type QueryResult

type QueryResult struct {
	*query.Result
}

type StmtIFacer

type StmtIFacer interface {
	ToSql() (string, []interface{}, error)
}

type Table

type Table struct {
	Name            string
	Fields          map[string]string
	IndexStatements []string
}

func NewTable

func NewTable(name string, fields map[string]string, indexStatements []string) *Table

func (*Table) CreateTable

func (t *Table) CreateTable() []string

Utility function for each consumer to create their own module each module will only then have to call this function to satisfy DBModel interface below

Jump to

Keyboard shortcuts

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