Documentation
¶
Index ¶
- Variables
- func RecordExists(ctx context.Context, exec bob.Executor, KeyPK string) (bool, error)
- func Where[Q sqlite.Filterable]() struct{ ... }
- type Record
- func (o *Record) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
- func (o *Record) Delete(ctx context.Context, exec bob.Executor) error
- func (o *Record) PrimaryKeyVals() bob.Expression
- func (o *Record) Reload(ctx context.Context, exec bob.Executor) error
- func (o *Record) Update(ctx context.Context, exec bob.Executor, s *RecordSetter) error
- type RecordSetter
- type RecordSlice
- func (o RecordSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
- func (o RecordSlice) DeleteAll(ctx context.Context, exec bob.Executor) error
- func (o RecordSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]
- func (o RecordSlice) ReloadAll(ctx context.Context, exec bob.Executor) error
- func (o RecordSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals RecordSetter) error
- func (o RecordSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]
- type RecordsQuery
- type UniqueConstraintError
Constants ¶
This section is empty.
Variables ¶
var ( SelectWhere = Where[*dialect.SelectQuery]() InsertWhere = Where[*dialect.InsertQuery]() UpdateWhere = Where[*dialect.UpdateQuery]() DeleteWhere = Where[*dialect.DeleteQuery]() )
var ( SelectJoins = getJoins[*dialect.SelectQuery] UpdateJoins = getJoins[*dialect.UpdateQuery] )
var ColumnNames = struct {
Records recordColumnNames
}{
Records: recordColumnNames{
Key: "key",
Format: "format",
Value: "value",
Created: "created",
Modified: "modified",
Expires: "expires",
Deleted: "deleted",
Secret: "secret",
Crownjewel: "crownjewel",
},
}
var ErrUniqueConstraint = &UniqueConstraintError{s: ""}
ErrUniqueConstraint captures all unique constraint errors by explicitly leaving `s` empty.
var RecordColumns = buildRecordColumns("records")
var Records = sqlite.NewTablex[*Record, RecordSlice, *RecordSetter]("", "records")
Records contains methods to work with the records table
var TableNames = struct { Records string }{ Records: "records", }
Functions ¶
func RecordExists ¶
RecordExists checks the presence of a single record by primary key
func Where ¶
func Where[Q sqlite.Filterable]() struct { Records recordWhere[Q] }
Types ¶
type Record ¶
type Record struct {
Key string `db:"key,pk" `
Format null.Val[int16] `db:"format" `
Value null.Val[[]byte] `db:"value" `
Created int64 `db:"created" `
Modified int64 `db:"modified" `
Expires int64 `db:"expires" `
Deleted int64 `db:"deleted" `
Secret bool `db:"secret" `
Crownjewel bool `db:"crownjewel" `
}
Record is an object representing the database table.
func FindRecord ¶
func FindRecord(ctx context.Context, exec bob.Executor, KeyPK string, cols ...string) (*Record, error)
FindRecord retrieves a single record by primary key If cols is empty Find will return all columns.
func (*Record) AfterQueryHook ¶
func (o *Record) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
AfterQueryHook is called after Record is retrieved from the database
func (*Record) PrimaryKeyVals ¶
func (o *Record) PrimaryKeyVals() bob.Expression
PrimaryKeyVals returns the primary key values of the Record
type RecordSetter ¶
type RecordSetter struct {
Key omit.Val[string] `db:"key,pk" `
Format omitnull.Val[int16] `db:"format" `
Value omitnull.Val[[]byte] `db:"value" `
Created omit.Val[int64] `db:"created" `
Modified omit.Val[int64] `db:"modified" `
Expires omit.Val[int64] `db:"expires" `
Deleted omit.Val[int64] `db:"deleted" `
Secret omit.Val[bool] `db:"secret" `
Crownjewel omit.Val[bool] `db:"crownjewel" `
}
RecordSetter is used for insert/upsert/update operations All values are optional, and do not have to be set Generated columns are not included
func (*RecordSetter) Apply ¶
func (s *RecordSetter) Apply(q *dialect.InsertQuery)
func (RecordSetter) Expressions ¶
func (s RecordSetter) Expressions(prefix ...string) []bob.Expression
func (RecordSetter) Overwrite ¶
func (s RecordSetter) Overwrite(t *Record)
func (RecordSetter) SetColumns ¶
func (s RecordSetter) SetColumns() []string
func (RecordSetter) UpdateMod ¶
func (s RecordSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery]
type RecordSlice ¶
type RecordSlice []*Record
RecordSlice is an alias for a slice of pointers to Record. This should almost always be used instead of []*Record.
func (RecordSlice) AfterQueryHook ¶
func (o RecordSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error
AfterQueryHook is called after RecordSlice is retrieved from the database
func (RecordSlice) DeleteMod ¶
func (o RecordSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery]
DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
func (RecordSlice) UpdateAll ¶
func (o RecordSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals RecordSetter) error
func (RecordSlice) UpdateMod ¶
func (o RecordSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery]
UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
type RecordsQuery ¶
type RecordsQuery = *sqlite.ViewQuery[*Record, RecordSlice]
RecordsQuery is a query on the records table
type UniqueConstraintError ¶
type UniqueConstraintError struct {
// contains filtered or unexported fields
}
func (*UniqueConstraintError) Error ¶
func (e *UniqueConstraintError) Error() string
func (*UniqueConstraintError) Is ¶
func (e *UniqueConstraintError) Is(target error) bool