Documentation
¶
Overview ¶
Package dbdefs has common definitions of types that are related to the database abstraction layer and database management
Index ¶
- type Adapter
- type ColumnName
- type ConditionValue
- type InnerTransactionFunc
- type MutationAdapter
- type MutationAdapterOverlay
- func (overlay MutationAdapterOverlay) Close() error
- func (overlay MutationAdapterOverlay) CreateCollectionFromModel(name string, model interface{}, ifNotExists bool) error
- func (overlay MutationAdapterOverlay) DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
- func (overlay MutationAdapterOverlay) Delete(cn string, obj interface{}) error
- func (overlay MutationAdapterOverlay) Insert(cn string, obj interface{}) error
- func (overlay MutationAdapterOverlay) IsConnected() bool
- func (overlay MutationAdapterOverlay) RunInTransaction(fn InnerTransactionFunc) error
- func (overlay MutationAdapterOverlay) Select(collectionName string, args interface{}) (interface{}, error)
- func (overlay MutationAdapterOverlay) SelectAdvanced(collectionName string, model interface{}, query *SelectQuery) error
- func (overlay MutationAdapterOverlay) SelectInto(collectionName string, args interface{}, model interface{}) error
- func (overlay MutationAdapterOverlay) SyncSchema(options SchemaSyncOptions, models ...interface{}) error
- func (overlay MutationAdapterOverlay) Update(cn string, obj interface{}) error
- type SchemaSyncOptions
- type SelectQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface { // SyncSchema creates tables and adds columns just like they are defined in the models SyncSchema(options SchemaSyncOptions, models ...interface{}) error // Close closes the database connection Close() error // Select fetches data from the database using the primary key inside args and // writes the result into args. The same result is returned as well. Select(collectionName string, args interface{}) (interface{}, error) // Select fetches data from the database using the primary key inside args and // writes the result into model. SelectInto(collectionName string, args interface{}, model interface{}) error // SelectAdvanced can be used to fetch data in a wide variety of ways including // but not limited to where/equals. SelectAdvanced(collectionName string, model interface{}, query *SelectQuery) error MutationAdapter // DataFromDatabaseUsingResolveParams uses the provided resolve parameters p to fetch // the requested data from the database and puts the result into objArr DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error // RunInTransaction creates a new transaction, does some overlaying to delegate // specific operations to the transaction and runs the given function inside of it. RunInTransaction(InnerTransactionFunc) error // IsConnected returns a bool indicating whether the connection to the database is // established and ready to use IsConnected() bool }
Use this interface to implement a database interface This will be used by the abstraction layer
type ColumnName ¶ added in v0.10.0
type ColumnName = string
type ConditionValue ¶ added in v0.10.0
type ConditionValue = interface{}
type InnerTransactionFunc ¶
type InnerTransactionFunc func(MutationAdapter) error
InnerTransactionFunc will be run inside a database transaction
type MutationAdapter ¶
type MutationAdapter interface { // CreateCollectionFromModel creates a new collection in the database // using the provided model as a schema CreateCollectionFromModel(name string, model interface{}, ifNotExists bool) error // Insert inserts the given obj into the collection denoted by collectionName // and writes the new entry into obj. This means after calling this you will // be able to use the new Id Insert(collectionName string, obj interface{}) error // Update updates the given obj in the collection given denoted by collectionName // using the primary key as index (usually Id) and writes the result into obj Update(collectionName string, obj interface{}) error // Delete deletes the given obj using the primary key as index (usually Id) Delete(collectionName string, obj interface{}) error }
type MutationAdapterOverlay ¶
type MutationAdapterOverlay struct { // FullAdapter is the original, full adapter FullAdapter Adapter // MutationAdapter provides a layer that interfaces with // a transaction as opposed to the FullAdapter which doesn't // use transactions at all MutationAdapter MutationAdapter }
MutationAdapterOverlay overlays the methods of the mutation adapter on top of the Adapter ones. This is mainly used to provide the abstracted RunInTransaction functionality while keeping the database API the same
func (MutationAdapterOverlay) Close ¶
func (overlay MutationAdapterOverlay) Close() error
func (MutationAdapterOverlay) CreateCollectionFromModel ¶
func (overlay MutationAdapterOverlay) CreateCollectionFromModel(name string, model interface{}, ifNotExists bool) error
func (MutationAdapterOverlay) DataFromDatabaseUsingResolveParams ¶
func (overlay MutationAdapterOverlay) DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
func (MutationAdapterOverlay) Delete ¶
func (overlay MutationAdapterOverlay) Delete(cn string, obj interface{}) error
func (MutationAdapterOverlay) Insert ¶
func (overlay MutationAdapterOverlay) Insert(cn string, obj interface{}) error
func (MutationAdapterOverlay) IsConnected ¶
func (overlay MutationAdapterOverlay) IsConnected() bool
func (MutationAdapterOverlay) RunInTransaction ¶
func (overlay MutationAdapterOverlay) RunInTransaction(fn InnerTransactionFunc) error
func (MutationAdapterOverlay) Select ¶
func (overlay MutationAdapterOverlay) Select(collectionName string, args interface{}) (interface{}, error)
func (MutationAdapterOverlay) SelectAdvanced ¶
func (overlay MutationAdapterOverlay) SelectAdvanced( collectionName string, model interface{}, query *SelectQuery) error
func (MutationAdapterOverlay) SelectInto ¶
func (overlay MutationAdapterOverlay) SelectInto( collectionName string, args interface{}, model interface{}) error
func (MutationAdapterOverlay) SyncSchema ¶
func (overlay MutationAdapterOverlay) SyncSchema(options SchemaSyncOptions, models ...interface{}) error
func (MutationAdapterOverlay) Update ¶
func (overlay MutationAdapterOverlay) Update(cn string, obj interface{}) error
type SchemaSyncOptions ¶
type SchemaSyncOptions struct { // Whether to remove columns from the database // that can't be found in models. // // *This is a potentially destructive option, only // enable if you're absolutely sure you want to remove // old columns* // // Note that this may not have an effect on document // or graph databases. RemoveOrphanedColumns bool // Model names (in case the collections have a different name) ModelNames []string }
type SelectQuery ¶
type SelectQuery struct { // Conditions Conditions map[ColumnName]ConditionValue /*GreaterThan interface{} SmallerThan interface{}*/ // IgnoreMultiple indicates whether in case of a result set // of greater length than 1 only the first result should be returned. // If you set this to true, only the first result will be returned. // If you set this to false, all results are returned as a slice. IgnoreMultiple bool }
SelectQuery can be used to describe a select query regardless of the database system used
Click to show internal directories.
Click to hide internal directories.