Documentation
¶
Overview ¶
Package data provides a data structure for defining simple database filters. This is not able to represent every imaginable query criteria, but it does a good job of making common criteria simple to format and pass around in your application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶ added in v0.3.8
type Collection interface {
Context() context.Context
Count(criteria exp.Expression, options ...option.Option) (int64, error)
Query(target any, criteria exp.Expression, options ...option.Option) error
Iterator(criteria exp.Expression, options ...option.Option) (Iterator, error)
Load(criteria exp.Expression, target Object, options ...option.Option) error
Save(object Object, note string) error
Delete(object Object, note string) error
HardDelete(criteria exp.Expression) error
}
Collection represents a single database collection (or table) that is opened to support a single transactional request, and then closed when this transaction is complete
type Iterator ¶ added in v0.2.5
Iterator interface allows callers to iterator over a large number of items in a data structure
type Object ¶
type Object interface {
// The unique identifier for this object
ID() string
// Unix epoch time when this object was created
Created() int64
// Unix epoch time when this object was updated
Updated() int64
// IsNew returns TRUE if the object has not yet been saved to the database
IsNew() bool
// IsDeleted returns TRUE if the object has been virtually deleted
IsDeleted() bool
// SetCreated stamps the CreateDate and UpdateDate of the object, and makes a note
SetCreated(comment string)
// SetUpdated stamps the UpdateDate of the object, and makes a note
SetUpdated(comment string)
// SetDeleted marks the object virtually "deleted", and makes a note
SetDeleted(comment string)
// ETag returns the signature or revision number of the object
ETag() string
}
Object interface defines all of the methods required for the `data` library to create, read, update, and delete objects in the database.
type Server ¶ added in v0.3.6
type Server interface {
Session(context.Context) (Session, error)
WithTransaction(context.Context, TransactionCallbackFunc) (any, error)
}
Server is an abstract representation of a database and its connection information.
type Session ¶
type Session interface {
Collection(collection string) Collection
Context() context.Context
Close()
}
Session represents a single database session, that is opened to support a single transactional request, and then closed when this transaction is complete
type TransactionCallbackFunc ¶ added in v0.31.0
TransactionCallbackFunc is a function that is called after a transaction session is created. The callback function can return a value (which is passed through) and an error. If the error is nil then the transaction is to be committed to the database. Othwerwise, the transaction is to be rolled back.