dbdefs

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: Unlicense Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	SyncSchema(options SchemaSyncOptions, models ...interface{}) error
	Close() error
	Select(collectionName string, args interface{}) (interface{}, error)
	SelectInto(collectionName string, args interface{}, model interface{}) error
	SelectAdvanced(collectionName string, model interface{}, query *SelectQuery) error
	MutationAdapter
	DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
	RunInTransaction(InnerTransactionFunc) error
	IsConnected() bool
}

Use this interface to implement a database interface This will be used by the abstraction layer

type InnerTransactionFunc

type InnerTransactionFunc func(MutationAdapter) error

type MutationAdapter

type MutationAdapter interface {
	CreateCollectionFromModel(name string, model interface{}, ifNotExists bool) error
	Insert(collectionName string, obj interface{}) error
	Update(collectionName string, obj interface{}) error
	Delete(collectionName string, obj interface{}) error
}

type MutationAdapterOverlay

type MutationAdapterOverlay struct {
	FullAdapter     Adapter
	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 {
	Where  string
	Equals interface{}
	/*GreaterThan interface{}
	SmallerThan interface{}*/
	IgnoreMultiple bool
}

Jump to

Keyboard shortcuts

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