Documentation ¶
Index ¶
- Variables
- func DeleteBy(db sq.BaseRunner, p *Proxy, by Values) (int64, error)
- func Put(db sq.BaseRunner, p *Proxy) (int64, error)
- func SetBuilderProvider(rdb provider)
- func Truncate(db sq.BaseRunner, p *Proxy) (err error)
- func Tx(db *sql.DB, pipes ...TxPipe) (err error)
- func Update(db sq.BaseRunner, p *Proxy, v Values) error
- type Changer
- type Collection
- type Finder
- type Modifier
- type Proxy
- func (p *Proxy) Collection() *Collection
- func (p *Proxy) Delete(db sq.BaseRunner) (int64, error)
- func (p *Proxy) DeleteBy(db sq.BaseRunner, by Values) (int64, error)
- func (p *Proxy) Fetch(db sq.BaseRunner) (*Collection, error)
- func (p *Proxy) Field(name string) reflect.Value
- func (p *Proxy) Find() *Finder
- func (p *Proxy) FindBy(q Qualifier) *Finder
- func (p *Proxy) Join(db sq.BaseRunner, in *Collection) (*Collection, error)
- func (p *Proxy) Load(db sq.BaseRunner) error
- func (p *Proxy) Map() Values
- func (p *Proxy) MustLoad(db sq.BaseRunner) *Proxy
- func (p *Proxy) Put(db sq.BaseRunner) (int64, error)
- func (p *Proxy) Query(b sq.SelectBuilder) *Finder
- func (p *Proxy) Truncate(db sq.BaseRunner) error
- func (p *Proxy) Update(db sq.BaseRunner, v Values) error
- type Qualifier
- type TxPipe
- type Values
- type Versionable
Constants ¶
This section is empty.
Variables ¶
var ( // MySQL describes behavior for LastInsertId and question placeholder MySQL = mysqlProvider{} // Postgres describes behavior for SERIAL data type and dollar placeholder Postgres = postgresProvider{} )
var ByEq = func(eq sq.Eq) Qualifier { return func(b sq.SelectBuilder) sq.SelectBuilder { return b.Where(eq) } }
ByEq returns the filter by squirrel.Eq
var ByID = func(id interface{}) Qualifier { return ByEq(sq.Eq{"id": id}) }
ByID returns the filter by ID
var Debug = true
Debug enables additional info
var (
ErrNoAffectedRows = errors.New("y/errors: no affected rows found")
)
Functions ¶
func SetBuilderProvider ¶
func SetBuilderProvider(rdb provider)
SetBuilderProvider defines statement builder type
Types ¶
type Changer ¶
type Changer struct {
// contains filtered or unexported fields
}
Changer updates object values
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection contains items and indexes
func Fetch ¶
func Fetch(db sq.BaseRunner, v interface{}) (*Collection, error)
Fetch loads a collection of objects
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder loads a collection from a database
func (*Finder) Fetch ¶
func (f *Finder) Fetch(db sq.BaseRunner) (*Collection, error)
Fetch make a query and creates a collection
type Modifier ¶
type Modifier func(v interface{}) interface{}
Modifier changes a value for update statement
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy contains a schema of a type
func (*Proxy) Collection ¶
func (p *Proxy) Collection() *Collection
Collection creates a collection of proxy values
func (*Proxy) Delete ¶
func (p *Proxy) Delete(db sq.BaseRunner) (int64, error)
Delete removes a proxy by primary
func (*Proxy) Fetch ¶
func (p *Proxy) Fetch(db sq.BaseRunner) (*Collection, error)
Fetch returns a collection of objects
func (*Proxy) Join ¶
func (p *Proxy) Join(db sq.BaseRunner, in *Collection) (*Collection, error)
Join adds related collection to self
func (*Proxy) Load ¶
func (p *Proxy) Load(db sq.BaseRunner) error
Load fetches an object from db by primary key
func (*Proxy) MustLoad ¶
func (p *Proxy) MustLoad(db sq.BaseRunner) *Proxy
MustLoad fetches an object and panic if an error occurred
type Qualifier ¶
type Qualifier func(sq.SelectBuilder) sq.SelectBuilder
Qualifier updates a select builder if you need
type Versionable ¶
Versionable mixins a version to a model
func MakeVersionable ¶
func MakeVersionable(n int64) Versionable
MakeVersionable inits a new version