Documentation ¶
Index ¶
- type Clause
- func And(clauses ...Clause) Clause
- func Between[T string | number](field string, from, to T) Clause
- func Contains[T string | number](field string, value T) Clause
- func ContainsAll[T string | number](field string, values ...T) Clause
- func ContainsAny[T string | number](field string, values ...T) Clause
- func Equal[T string | number](field string, value T) Clause
- func GreaterThan[T string | number](field string, value T) Clause
- func GreaterThanOrEqual[T string | number](field string, value T) Clause
- func In(field string, values ...any) Clause
- func LessThan[T string | number](field string, value T) Clause
- func LessThanOrEqual[T string | number](field string, value T) Clause
- func Like(field string, value string) Clause
- func NotEqual[T string | number](field string, value T) Clause
- func Or(clauses ...Clause) Clause
- type Store
- type Table
- func (n *Table[T]) Count(ctx context.Context) (uint64, error)
- func (n *Table[T]) CreateIndex(ctx context.Context, fields ...string) (string, error)
- func (n *Table[T]) CreateIndexes(ctx context.Context, indexes ...[]string) ([]string, error)
- func (n *Table[T]) CreateTable(ctx context.Context) error
- func (n *Table[T]) Delete(ctx context.Context, clause Clause) error
- func (n *Table[T]) Insert(ctx context.Context, data T) error
- func (n *Table[T]) QueryMany(ctx context.Context, clause Clause) ([]T, error)
- func (n *Table[T]) QueryOne(ctx context.Context, clause Clause) (*T, error)
- func (n *Table[T]) Update(ctx context.Context, clause Clause, newVal T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clause ¶
type Clause interface { // Clause returns the clause as a string using parameters for values Clause() string // Values returns the values to assign to the parameters in the clause Values() []any And(c Clause) Clause Or(c Clause) Clause }
Clause represents a clause in a query
func Contains ¶ added in v0.2.0
Contains returns a clause that checks if a list field contains a single value
func ContainsAll ¶ added in v0.2.0
func ContainsAny ¶ added in v0.2.0
func GreaterThan ¶
GreaterThan returns a clause that checks if a field is greater than a value
func GreaterThanOrEqual ¶
GreaterThanOrEqual returns a clause that checks if a field is greater than or equal to a value
func LessThanOrEqual ¶
LessThanOrEqual returns a clause that checks if a field is less than or equal to a value
func Like ¶
Like returns a clause that checks if a field is like a value It's up to the user to add the requisite % characters
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents a store for the database
func NewStoreWithDB ¶
NewStoreWithDB creates a new store with the given database
type Table ¶
type Table[T any] struct { // Name of the table Name string // contains filtered or unexported fields }
Table represents a table in the database
func (*Table[T]) CreateIndex ¶
CreateIndex creates an index on the given fields
func (*Table[T]) CreateIndexes ¶ added in v0.3.0
func (*Table[T]) CreateTable ¶
CreateTable creates the table if it does not exist
func (*Table[T]) QueryMany ¶
QueryMany returns multiple items from the table can we use http://doug-martin.github.io/goqu/ for this?