Documentation
¶
Overview ¶
Package database is an abstraction layer for database systems
Index ¶
- Constants
- type Adapter
- type Collection
- func (c *Collection) DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
- func (c *Collection) Delete(obj interface{}) error
- func (c *Collection) EnsureInTx() error
- func (c *Collection) Insert(obj interface{}) error
- func (c *Collection) IsInTx() bool
- func (c *Collection) RunInTransaction(fn TransactionFunc) error
- func (c *Collection) Select(arguments interface{}) (interface{}, error)
- func (c *Collection) SelectAdvanced(model interface{}, query *SelectQuery) error
- func (c *Collection) SelectInto(arguments interface{}, model interface{}) error
- func (c *Collection) Update(obj interface{}) error
- func (c *Collection) WithoutTx() *Collection
- type Database
- 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) 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 Relation
- type RelationSolveContext
- type SchemaSyncOptions
- type SelectQuery
- type StructFieldName
- type StructFieldRelationMap
- type TransactionFunc
- type TypeName
- type TypeRelationsMap
Constants ¶
View Source
const ( TagPrefix = "goqlorm.relation." TagRelationType = TagPrefix + "type" TagLinkTo = TagPrefix + "linkTo" TagLinkFrom = TagPrefix + "linkFrom" TagInversedBy = TagPrefix + "inversedBy" )
Tags
View Source
const (
AssocFieldPrefix = "Assoc"
)
View Source
const (
ErrorMustBeInTx = "can't do %s, mutations must be run in a transaction"
)
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 }
Use this interface to implement a database interface This will be used by the abstraction layer
type Collection ¶ added in v0.4.0
type Collection struct { Name string // contains filtered or unexported fields }
func (*Collection) DataFromDatabaseUsingResolveParams ¶ added in v0.5.3
func (c *Collection) DataFromDatabaseUsingResolveParams( objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
func (*Collection) Delete ¶ added in v0.5.1
func (c *Collection) Delete(obj interface{}) error
func (*Collection) EnsureInTx ¶ added in v0.6.2
func (c *Collection) EnsureInTx() error
func (*Collection) Insert ¶ added in v0.5.1
func (c *Collection) Insert(obj interface{}) error
func (*Collection) IsInTx ¶ added in v0.6.2
func (c *Collection) IsInTx() bool
func (*Collection) RunInTransaction ¶ added in v0.5.1
func (c *Collection) RunInTransaction(fn TransactionFunc) error
func (*Collection) Select ¶ added in v0.4.0
func (c *Collection) Select(arguments interface{}) (interface{}, error)
func (*Collection) SelectAdvanced ¶ added in v0.5.1
func (c *Collection) SelectAdvanced(model interface{}, query *SelectQuery) error
func (*Collection) SelectInto ¶ added in v0.5.1
func (c *Collection) SelectInto(arguments interface{}, model interface{}) error
func (*Collection) Update ¶ added in v0.5.1
func (c *Collection) Update(obj interface{}) error
func (*Collection) WithoutTx ¶ added in v0.6.0
func (c *Collection) WithoutTx() *Collection
type Database ¶ added in v0.3.1
type Database struct {
// contains filtered or unexported fields
}
func Get ¶ added in v0.3.1
func Get(adapter Adapter, schemaSyncOptions SchemaSyncOptions, models ...interface{}) *Database
func (*Database) Collection ¶ added in v0.4.0
func (db *Database) Collection(model interface{}) *Collection
func (*Database) CustomCollection ¶ added in v0.5.1
func (db *Database) CustomCollection(name string) *Collection
func (*Database) SkipOnNonInsert ¶ added in v0.6.2
func (db *Database) SkipOnNonInsert(model interface{}, field reflect.StructField) bool
type InnerTransactionFunc ¶ added in v0.4.2
type InnerTransactionFunc func(MutationAdapter) error
type MutationAdapter ¶ added in v0.4.2
type MutationAdapterOverlay ¶ added in v0.4.2
type MutationAdapterOverlay struct {
// contains filtered or unexported fields
}
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 ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) Close() error
func (MutationAdapterOverlay) CreateCollectionFromModel ¶ added in v0.5.3
func (overlay MutationAdapterOverlay) CreateCollectionFromModel(name string, model interface{}, ifNotExists bool) error
func (MutationAdapterOverlay) DataFromDatabaseUsingResolveParams ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) DataFromDatabaseUsingResolveParams(objArr interface{}, modelType reflect.Type, p graphql.ResolveParams) error
func (MutationAdapterOverlay) Delete ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) Delete(cn string, obj interface{}) error
func (MutationAdapterOverlay) Insert ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) Insert(cn string, obj interface{}) error
func (MutationAdapterOverlay) RunInTransaction ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) RunInTransaction(fn InnerTransactionFunc) error
func (MutationAdapterOverlay) Select ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) Select(collectionName string, args interface{}) (interface{}, error)
func (MutationAdapterOverlay) SelectAdvanced ¶ added in v0.5.1
func (overlay MutationAdapterOverlay) SelectAdvanced( collectionName string, model interface{}, query *SelectQuery) error
func (MutationAdapterOverlay) SelectInto ¶ added in v0.5.1
func (overlay MutationAdapterOverlay) SelectInto( collectionName string, args interface{}, model interface{}) error
func (MutationAdapterOverlay) SyncSchema ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) SyncSchema(options SchemaSyncOptions, models ...interface{}) error
func (MutationAdapterOverlay) Update ¶ added in v0.4.2
func (overlay MutationAdapterOverlay) Update(cn string, obj interface{}) error
type Relation ¶ added in v0.4.0
type Relation struct { ModelType reflect.Type Field reflect.StructField LinkedType reflect.Type LinkedTo reflect.StructField LinkedFrom reflect.StructField Associations *Collection AssociateFrom reflect.StructField AssociateTo reflect.StructField AssociationType reflect.Type Type relationtype.RelationType InversedBy *reflect.StructField }
type RelationSolveContext ¶ added in v0.6.0
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 ¶ added in v0.5.1
type StructFieldName ¶ added in v0.4.0
type StructFieldName = string
type StructFieldRelationMap ¶ added in v0.4.0
type StructFieldRelationMap map[StructFieldName]*Relation
type TransactionFunc ¶ added in v0.4.2
type TransactionFunc func(txDb *Collection) error
type TypeRelationsMap ¶ added in v0.4.0
type TypeRelationsMap map[TypeName]StructFieldRelationMap
Click to show internal directories.
Click to hide internal directories.