Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection interface {
Init(interface{}) error
ExecRaw(context.Context, string) error
// Modify Operations
Filter(Predicate) Collection
Edit(Operation) Collection
Insert(context.Context, interface{}) error
Delete(context.Context) error
Update(context.Context) error
// Read Operations
List(context.Context, interface{}) error
Page(context.Context, int) (Paginator, error)
Single(context.Context, interface{}) error
// C returns the internal composite type, if it exists. Nil otherwise
C() Collection
}
Collection defines a grouping of related entities that can be created, searched, filtered, updated, and deleted.
type Operation ¶
type Operation interface {
Apply(c Collection) error
}
Operation defines a piece of code that modifies a writing statement
type Paginator ¶
type Paginator interface {
// Apply pushes the current page of results into the given slice
Apply(context.Context, interface{}) error
// PageCount returns the number of pages
PageCount() int
// ItemCount returns the total number of items
ItemCount() int
// CurrentPage returns the current page
CurrentPage() int
// PerPageCount returns how many items are going to be on each page
PerPageCount() int
// Next moves to the next page, returning false if we are out of pages
Next() bool
// Prev moves to the previous page, returning false if we are out of pages
Prev() bool
}
Paginator is the stateful object for allowing page based iteration of a collection.
type Predicate ¶
type Predicate interface {
Apply(c Collection) error
}
Predicate defines a piece of code that modifies a reading statement.
type Transaction ¶
A Transaction is a unit of work against a database.
type Transactioner ¶
type Transactioner interface {
BeginTx() (Transaction, error)
}
Transactioner marks a collection as something that supports starting transactions.
type ValueColumn ¶
type ValueColumn interface {
// Name is the column name
Name() string
// Type is the column type (sql type, redis type, etc)
Type() string
// Eq returns a predicate that, when applied to a Collection, filters out matching elements
Eq(interface{}) Predicate
// NotEq returns a predicate that, when applied to a Collection, filters out non-matching elements
NotEq(interface{}) Predicate
// Like returns a predicate that, when applied to a Collection, filters out wildcard matching elements
Like(bool, interface{}) Predicate
// Set returns the operation that, when applied to a collection, updates the elements
Set(interface{}) Operation
}
ValueColumn defines a column defined on a collection.