Documentation ¶
Index ¶
- func AclDSFactory(acl ds.IDataSource) (ds.IAclDataSource, error)
- func ByID(tx *sql.Tx, t ITable, v ...interface{}) error
- func Db() *sql.DB
- func Init() error
- func PinDSFactory(pin, user ds.IDataSource) (ds.IPinDataSource, error)
- func UserDSFactory(user ds.IDataSource) (ds.IUserDataSource, error)
- type ITable
- type NotITableError
- type Table
- func (Table) AfterDelete(qo *ds.QueryOptions, tx *sql.Tx) error
- func (Table) AfterInsert(qo *ds.QueryOptions, tx *sql.Tx) error
- func (Table) AfterSelect(qo *ds.QueryOptions) error
- func (Table) AfterUpdate(qo *ds.QueryOptions, tx *sql.Tx) error
- func (Table) BeforeDelete(qo *ds.QueryOptions, tx *sql.Tx) (ds.Params, error)
- func (Table) BeforeInsert(qo *ds.QueryOptions, tx *sql.Tx) error
- func (Table) BeforeSelect(qo *ds.QueryOptions) (ds.Params, error)
- func (Table) BeforeUpdate(qo *ds.QueryOptions, tx *sql.Tx) error
- func (Table) Count(qo *ds.QueryOptions) (count int64, err error)
- func (Table) Delete(qo *ds.QueryOptions) (int64, error)
- func (Table) Fetch(qo *ds.QueryOptions) (meta ds.ResultSetMeta, data []interface{}, err error)
- func (Table) Find(qo *ds.QueryOptions) (meta ds.ResultSetMeta, data interface{}, err error)
- func (Table) Insert(qo *ds.QueryOptions) error
- func (Table) Update(qo *ds.QueryOptions) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AclDSFactory ¶
func AclDSFactory(acl ds.IDataSource) (ds.IAclDataSource, error)
UserDSFactory returns an object that implements user.IUserDataSource.
func PinDSFactory ¶
func PinDSFactory(pin, user ds.IDataSource) (ds.IPinDataSource, error)
PinDSFactory returns an object that implements pin.IPinDataSource.
func UserDSFactory ¶
func UserDSFactory(user ds.IDataSource) (ds.IUserDataSource, error)
UserDSFactory returns an object that implements user.IUserDataSource.
Types ¶
type ITable ¶
type ITable interface { // ITable interfaces must fulfills ds.IDataSource ds.IDataSource // BeforeSelect offers a chance optionally set additional constraints // in a per Table basis, or abort the select by returning an error. BeforeSelect(qo *ds.QueryOptions) (ds.Params, error) // AfterSelect offers a chance to optionally modify a selected result and attach parent // table data in a per Table basis, or abort the select by returning an error. AfterSelect(qo *ds.QueryOptions) error // BeforeInsert offers a chance to complete extra validations, alter values, // or abort the insert by returning an error. // Consider using *ds.NotAllowedError and/or *ds.ValidationErrors, these // will be treated as such by ctrl.CrudController, others will be considered // InternalServerError's. BeforeInsert(qo *ds.QueryOptions, tx *sql.Tx) error // AfterInsert offers a chance to complete extra validations, alter values, // or abort the insert by returning an error. // Consider using *ds.NotAllowedError and/or *ds.ValidationErrors, these // will be treated as such by ctrl.CrudController, others will be considered // InternalServerError's. AfterInsert(qo *ds.QueryOptions, tx *sql.Tx) error // BeforeUpdate offers a chance to complete extra validations, alter values, // or abort the update by returning an error. // Consider using *ds.NotAllowedError and/or *ds.ValidationErrors, these // will be treated as such by ctrl.CrudController, others will be considered // InternalServerError's. // Consider using tx for any db modification here. BeforeUpdate(qo *ds.QueryOptions, tx *sql.Tx) error // AfterUpdate offers a chance to complete extra actions // or abort the update by returning an error. // Consider using *ds.NotAllowedError and/or validator.validationErrors, these // will be treated as such by ctrl.CrudController, others will be considered // InternalServerError's. // Consider using tx for any db modification here. AfterUpdate(qo *ds.QueryOptions, tx *sql.Tx) error // BeforeDelete offers a chance optionally set additional constraints // in a per Table basis, or even abort the delete by returning an error. // Consider using tx for any db modification here. BeforeDelete(qo *ds.QueryOptions, tx *sql.Tx) (ds.Params, error) // AfterDelete offers a chance to complete extra actions after the delete // or even abort the delete by returning an error. // Consider using tx for any db modification here. AfterDelete(qo *ds.QueryOptions, tx *sql.Tx) error }
ITable defines an interface for db table access. Consider annonymous embedding of Table in your concrete ITable. Table offers default implementation for all ITable and ds.IDataSource methods, except Name(). You can always overwrite the methods you need to. Check Table for more information.
type Table ¶
type Table struct{}
Table offers default implementation for all ITable and ds.IDataSource methods, except Name(). Consider annonymous embedding of Table in your concrete ITable.
func (Table) AfterDelete ¶
func (Table) AfterInsert ¶
func (Table) AfterSelect ¶
func (Table) AfterSelect(qo *ds.QueryOptions) error
func (Table) AfterUpdate ¶
func (Table) BeforeDelete ¶
func (Table) BeforeInsert ¶
func (Table) BeforeSelect ¶
func (Table) BeforeUpdate ¶
func (Table) Count ¶
func (Table) Count(qo *ds.QueryOptions) (count int64, err error)
Count returns the number of qo.DataSource records that match qo settings. Beware that qo.DataSource must implement ITable.
func (Table) Delete ¶
func (Table) Delete(qo *ds.QueryOptions) (int64, error)
Delete supports single and multiple records removal. It first checks with Table's BeforeDelete method for extra constraints. BeforeDelete can also return a *ds.NotAllowedError to abort Delete. Beware that qo.DataSource must implement ITable.
func (Table) Fetch ¶
func (Table) Fetch(qo *ds.QueryOptions) (meta ds.ResultSetMeta, data []interface{}, err error)
Fetch returns the qo.DataSource records that match qo settings. Supports BeforeSelect(qo) and parent data retrieval through dig params. If a parent resource is not found, Fetch is aborted with a NotFoundError. Beware that qo.DataSource must implement ITable.
func (Table) Find ¶
func (Table) Find(qo *ds.QueryOptions) (meta ds.ResultSetMeta, data interface{}, err error)
Find returns the qo.DataSource record that matches qo settings. Supports BeforeSelect(qo) and AfterSelect(qo). AfterSelect allows parent data retrieval through dig params. If a parent resource is not found, Find is aborted with a NotFoundError. Beware that qo.DataSource must implement ITable.