Documentation
¶
Index ¶
- Variables
- func Delete(db *sql.DB, m Model) error
- func QuerySlice(db *sql.DB, opts *Options, out interface{}) error
- func QuerySliceContext(ctx context.Context, db *sql.DB, opts *Options, out interface{}) error
- func QueryStruct(db *sql.DB, opts *Options, out Model) error
- func QueryStructContext(ctx context.Context, db *sql.DB, opts *Options, out Model) error
- func Upsert(db *sql.DB, m Model) error
- func UpsertContext(ctx context.Context, db *sql.DB, m Model) error
- type Model
- type Options
- type OrderBy
- type Where
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoRowsAffected = errors.New("no rows affected")
Functions ¶
func QuerySlice ¶
QuerySlice scans rows into the slice of structs
func QuerySliceContext ¶ added in v0.0.5
QuerySliceContext scans rows into the slice of structs with given context
func QueryStruct ¶
QueryStruct looks up for rows in given table and scans it to provided struct or slice of structs
func QueryStructContext ¶ added in v0.0.5
QueryStruct looks up for rows in given table and scans it to provided struct or slice of structs
Types ¶
type Model ¶
type Model interface {
Table() string
}
Model is an interface that represents model of database
type Options ¶
type Options struct {
Where Where `json:"where"`
Limit int `json:"limit"`
Offset int `json:"offset"`
OrderBy *OrderBy `json:"order_by"`
RelationDepth int `json:"relation_depth"`
}
Options represents query options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default options for query
func WithOffset ¶
WithOffset modifies existing options by adding offset parameter to them. If options does not have positive limit parameter the offset will remain unchanged to avoid sql query correctness.
Click to show internal directories.
Click to hide internal directories.