Documentation
¶
Overview ¶
Package repository provides methods for interacting with the database
Index ¶
- func NewRecordID() string
- func NewRecordNullTimestamp() sql.NullTime
- func NewRecordTimestamp() time.Time
- func RecordDiff(p, pp EquatableRecord, flags ...EqualityFlag) (diff.Changelog, error)
- func RecordEqual(p, pp EquatableRecord, flags ...EqualityFlag) (bool, error)
- type Config
- type EqualityFlag
- type EquatableRecord
- type Record
- type Repository
- func (r *Repository) ArrayFields() set.Set[string]
- func (r *Repository) Attributes() []string
- func (r *Repository) CreateOneRec(rec interface{}) error
- func (r *Repository) CreateOneSQL() string
- func (r *Repository) DeleteManySQL() string
- func (r *Repository) DeleteOne(id any) error
- func (r *Repository) DeleteOneSQL() string
- func (r *Repository) GetManyRecs(opts *coresql.Options) (rows *sqlx.Rows, err error)
- func (r *Repository) GetManySQL() string
- func (r *Repository) GetOneRec(recordID any, rec any, lock *coresql.Lock) error
- func (r *Repository) GetOneSQL() string
- func (r *Repository) Init() error
- func (r *Repository) ReadonlyAttributes() []string
- func (r *Repository) RemoveManySQL() string
- func (r *Repository) RemoveOne(id any) error
- func (r *Repository) RemoveOneSQL() string
- func (r *Repository) TableName() string
- func (r *Repository) UpdateManySQL() string
- func (r *Repository) UpdateOneRec(rec interface{}) error
- func (r *Repository) UpdateOneSQL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordDiff ¶
func RecordDiff(p, pp EquatableRecord, flags ...EqualityFlag) (diff.Changelog, error)
func RecordEqual ¶
func RecordEqual(p, pp EquatableRecord, flags ...EqualityFlag) (bool, error)
Types ¶
type Config ¶
type Config struct { TableName string Attributes []string ReadonlyAttributes []string ArrayFields set.Set[string] }
Config -
type EqualityFlag ¶
type EqualityFlag string
const EqualityFlagExcludeID EqualityFlag = "eo-exclude-id"
const EqualityFlagExcludeTimestamps EqualityFlag = "flag-exclude-timestamps"
type EquatableRecord ¶
type EquatableRecord interface {
// contains filtered or unexported methods
}
type Record ¶
type Record struct { ID string `db:"id"` CreatedAt time.Time `db:"created_at"` UpdatedAt sql.NullTime `db:"updated_at"` DeletedAt sql.NullTime `db:"deleted_at"` }
Record -
type Repository ¶
type Repository struct { Config Config Log logger.Logger Tx *sqlx.Tx Prepare preparer.Repository // contains filtered or unexported fields }
Repository -
func (*Repository) ArrayFields ¶
func (r *Repository) ArrayFields() set.Set[string]
func (*Repository) Attributes ¶
func (r *Repository) Attributes() []string
func (*Repository) CreateOneRec ¶
func (r *Repository) CreateOneRec(rec interface{}) error
CreateOneRec -
func (*Repository) CreateOneSQL ¶
func (r *Repository) CreateOneSQL() string
CreateOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) DeleteManySQL ¶
func (r *Repository) DeleteManySQL() string
DeleteManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) DeleteOneSQL ¶
func (r *Repository) DeleteOneSQL() string
DeleteOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) GetManyRecs ¶
GetManyRecs -
func (*Repository) GetManySQL ¶
func (r *Repository) GetManySQL() string
GetManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) GetOneSQL ¶
func (r *Repository) GetOneSQL() string
GetOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) ReadonlyAttributes ¶
func (r *Repository) ReadonlyAttributes() []string
func (*Repository) RemoveManySQL ¶
func (r *Repository) RemoveManySQL() string
RemoveManySQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) RemoveOneSQL ¶
func (r *Repository) RemoveOneSQL() string
RemoveOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.
func (*Repository) UpdateOneRec ¶
func (r *Repository) UpdateOneRec(rec interface{}) error
UpdateOneRec -
func (*Repository) UpdateOneSQL ¶
func (r *Repository) UpdateOneSQL() string
UpdateOneSQL - This SQL statement ends with a newline so that any parameters can be easily appended.