Documentation ¶
Index ¶
- Constants
- type Condition
- func (c *Condition) Eq(val any) *Query
- func (c *Condition) Ge(val any) *Query
- func (c *Condition) Gt(val any) *Query
- func (c *Condition) In(vals ...any) *Query
- func (c *Condition) Le(val any) *Query
- func (c *Condition) Lt(val any) *Query
- func (c *Condition) Ne(val any) *Query
- func (c *Condition) NotIn(vals ...any) *Query
- func (c *Condition) Op() string
- func (c *Condition) Search(val any) *Query
- func (c *Condition) Value() any
- func (c *Condition) ValueList() []any
- type Empty
- type Key
- type Query
- func (q *Query) And(field string) *Condition
- func (q *Query) From(kind string) *Query
- func (q *Query) GetAttributes() []string
- func (q *Query) GetConditions() map[string][]*Condition
- func (q *Query) GetLimit() int
- func (q *Query) GetOrderBy() []string
- func (q *Query) GetSkip() int
- func (q *Query) Kind() string
- func (q *Query) Limit(limit int) *Query
- func (q *Query) OrderBy(args ...string) *Query
- func (q *Query) Skip(offset int) *Query
- func (q *Query) String() string
- func (q *Query) Where(attr string) *Condition
- type Record
- type RecordQueryer
- type RecordSet
- type RecordStorer
- type ResultSet
- type Tuple
- type Value
Constants ¶
const ( OpEq = "==" OpNe = "!=" OpGt = ">" OpGe = ">=" OpLt = "<" OpLe = "<=" OpIn = "IN" OpNotIn = "NOT IN" OpSearch = "SEARCH" ASC = "ASC" DESC = "DESC" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition defines an operator and a value to filter records.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a unique identifier for a record.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a commmon abstraction for querying, filtering, and sorting records.
func Select ¶
Select creates a new query to fetch records with the given attributes. Example:
q := Select("name", "age") q := Select("*") // fetch all attributes
func (*Query) GetAttributes ¶
GetAttributes returns the attributes of the query.
func (*Query) GetConditions ¶
GetConditions returns the conditions of the query.
func (*Query) GetOrderBy ¶
GetOrderBy returns the sorting order of the query.
func (*Query) OrderBy ¶
OrderBy adds a sorting order to the query. Accepts pairs of attribute and direction. Example:
q.OrderBy("name", "asc") q.OrderBy("age", "desc")
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
type RecordQueryer ¶
RecordQueryer defines the interface for querying records.
type RecordStorer ¶
type RecordStorer interface { GetRecord(ctx context.Context, key *Key) (*Record, error) PutRecord(ctx context.Context, record *Record) error DeleteRecord(ctx context.Context, key *Key) error }
RecordStorer defines the interface for storing and retrieving records.
type ResultSet ¶
type ResultSet[T any] struct { // contains filtered or unexported fields }
ResultSet is a paginated list of T.
func NewResultSet ¶
NewResultSet creates a new ResultSet.