Documentation ¶
Index ¶
- func Delete(ctx context.Context, db *sql.DB, flavor Flavor, tableName string, ...) error
- func DeleteQuery(flavor Flavor, tableName string, id interface{}) (string, []interface{})
- func FindAllQuery(tableName string, options *FindAllOptions) (string, []interface{})
- func FindQuery(tableName string, options *FindOptions) (string, []interface{})
- func Get(ctx context.Context, db *sql.DB, tableName string, options *FindOptions, ...) error
- func Insert(ctx context.Context, db *sql.DB, flavor Flavor, tag, tableName string, ...) error
- func InsertQuery(flavor Flavor, tag, tableName string, structValue interface{}) (string, []interface{})
- func Select(ctx context.Context, db *sql.DB, tableName string, options *FindAllOptions, ...) error
- func Update(ctx context.Context, db *sql.DB, flavor Flavor, tag, tableName string, ...) error
- func UpdateQuery(flavor Flavor, tag, tableName string, id interface{}, structValue interface{}) (string, []interface{})
- type FindAllOptions
- func (f *FindAllOptions) WithFields(fields []string) *FindAllOptions
- func (f *FindAllOptions) WithFilter(field string, value interface{}) *FindAllOptions
- func (f *FindAllOptions) WithLimit(limit int) *FindAllOptions
- func (f *FindAllOptions) WithOffset(offset int) *FindAllOptions
- func (f *FindAllOptions) WithOrderBy(orderBy string) *FindAllOptions
- type FindOptions
- type Flavor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteQuery ¶
DeleteQuery returns compiled DELETE string and args.
func FindAllQuery ¶
func FindAllQuery(tableName string, options *FindAllOptions) (string, []interface{})
FindAllQuery returns compiled SELECT string and args.
func FindQuery ¶
func FindQuery(tableName string, options *FindOptions) (string, []interface{})
FindQuery returns compiled SELECT string and args.
func Get ¶
func Get(ctx context.Context, db *sql.DB, tableName string, options *FindOptions, dst interface{}) error
Get is a high-level function that calls FindQuery and scany sqlscan.Get function.
func Insert ¶
func Insert(ctx context.Context, db *sql.DB, flavor Flavor, tag, tableName string, structValue interface{}) error
Insert is a high-level function that calls InsertQuery and db.ExecContext.
func InsertQuery ¶
func InsertQuery(flavor Flavor, tag, tableName string, structValue interface{}) (string, []interface{})
InsertQuery returns compiled INSERT string and args.
func Select ¶
func Select(ctx context.Context, db *sql.DB, tableName string, options *FindAllOptions, dst interface{}) error
Select is a high-level function that calls FindAllQuery and scany sqlscan.Select function.
func Update ¶
func Update(ctx context.Context, db *sql.DB, flavor Flavor, tag, tableName string, id interface{}, structValue interface{}) error
Update is a high-level function that calls UpdateQuery and db.ExecContext.
func UpdateQuery ¶
func UpdateQuery(flavor Flavor, tag, tableName string, id interface{}, structValue interface{}) (string, []interface{})
UpdateQuery returns compiled UPDATE string and args.
Types ¶
type FindAllOptions ¶
type FindAllOptions struct { Flavor Flavor Fields []string Filters map[string]interface{} Limit int Offset int OrderBy string }
FindAllOptions provides configuration for FindAllQuery function.
func NewFindAllOptions ¶
func NewFindAllOptions(flavor Flavor) *FindAllOptions
NewFindAllOptions returns a FindAllOptions.
func (*FindAllOptions) WithFields ¶
func (f *FindAllOptions) WithFields(fields []string) *FindAllOptions
WithFields is a helper function to construct functional options that sets Fields field.
func (*FindAllOptions) WithFilter ¶
func (f *FindAllOptions) WithFilter(field string, value interface{}) *FindAllOptions
WithFilter is a helper function to construct functional options that sets Filters field.
func (*FindAllOptions) WithLimit ¶
func (f *FindAllOptions) WithLimit(limit int) *FindAllOptions
WithLimit is a helper function to construct functional options that sets Limit field.
func (*FindAllOptions) WithOffset ¶
func (f *FindAllOptions) WithOffset(offset int) *FindAllOptions
WithOffset is a helper function to construct functional options that sets Offset field.
func (*FindAllOptions) WithOrderBy ¶
func (f *FindAllOptions) WithOrderBy(orderBy string) *FindAllOptions
WithOrderBy is a helper function to construct functional options that sets OrderBy field.
type FindOptions ¶
FindOptions provides configuration for FindQuery function.
func NewFindOptions ¶
func NewFindOptions(flavor Flavor) *FindOptions
NewFindOptions returns a FindOptions.
func (*FindOptions) WithFields ¶
func (f *FindOptions) WithFields(fields []string) *FindOptions
WithFields is a helper function to construct functional options that sets Fields field.
func (*FindOptions) WithFilter ¶
func (f *FindOptions) WithFilter(field string, value interface{}) *FindOptions
WithFilter is a helper function to construct functional options that sets Filters field.