Documentation ¶
Index ¶
- Constants
- Variables
- func Count(db *sql.DB, m Model, opts *Options) (count int64, err error)
- func Delete(db *sql.DB, m Model) (sql.Result, error)
- func Insert(db *sql.DB, m Model) error
- func InsertContext(ctx context.Context, db *sql.DB, m Model) error
- func IsFKError(err error) bool
- func IsNotFound(err error) bool
- func IsNotNullError(err error) bool
- func IsUniqueViolation(err error) bool
- 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 Update(db *sql.DB, m Model) error
- func UpdateContext(ctx context.Context, db *sql.DB, m Model, deep bool) error
- func UpdateDeep(db *sql.DB, m Model) error
- func Upsert(db *sql.DB, m Model) error
- func UpsertContext(ctx context.Context, db *sql.DB, m Model) error
- type BitwiseAND
- type BitwiseANDStrict
- type Error
- type Expression
- type Greater
- type GreaterOrEqual
- type IModel
- type Less
- type LessOrEqual
- type Model
- type NotEqual
- type Options
- type OrderBy
- type StrictString
- type Where
Constants ¶
const ( // AND is a glue between multiple statements after `where` AND = " and " // OR is a glue between multiple statements after `where` OR = " or " )
Variables ¶
var ( // ErrNoRowsAffected is an error to return when no rows were affected ErrNoRowsAffected = errors.New("no rows affected") )
Functions ¶
func InsertContext ¶ added in v0.2.3
func IsNotFound ¶ added in v0.2.3
func IsNotNullError ¶ added in v0.2.3
func IsUniqueViolation ¶ added in v0.2.3
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
QueryStructContext looks up for rows in given table and scans it to provided struct or slice of structs
func UpdateContext ¶ added in v0.2.3
UpdateContext updates model by it's primary keys
func UpdateDeep ¶ added in v0.2.3
UpdateDeep is the same as Update but also updates model's relations
Types ¶
type BitwiseAND ¶ added in v0.2.3
type BitwiseAND float64
type BitwiseANDStrict ¶ added in v0.2.3
type BitwiseANDStrict float64
type Expression ¶ added in v0.2.3
type GreaterOrEqual ¶ added in v0.2.3
type GreaterOrEqual float64
type LessOrEqual ¶ added in v0.2.3
type LessOrEqual float64
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"` Divider string `json:"divider"` Limit int `json:"limit"` Offset int `json:"offset"` OrderBy *OrderBy `json:"order_by"` RelationDepth int `json:"relation_depth"` RelatedTo []IModel `json:"related"` // contains filtered or unexported fields }
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.
type StrictString ¶ added in v0.2.3
type StrictString string