Documentation
¶
Index ¶
- Variables
- type Common
- type DBList
- type DBObject
- type DBS
- type DBU
- func (db DBU) Add(o DBObject) error
- func (db DBU) Delete(o DBObject) error
- func (db DBU) DeleteByID(o DBObject, id interface{}) error
- func (db DBU) Find(o DBObject, keys map[string]interface{}) error
- func (db DBU) FindBy(o DBObject, key string, value interface{}) error
- func (db DBU) FindByID(o DBObject, value interface{}) error
- func (db DBU) FindSelf(o DBObject) error
- func (db DBU) List(list DBList) error
- func (db DBU) ListQuery(list DBList, extra string) error
- func (db DBU) Replace(o DBObject) error
- func (db DBU) Save(o DBObject) error
- func (db DBU) SetLogger(logger *log.Logger)
- type SQLDB
- type SetHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoKeyField is returned for tables without primary key identified ErrNoKeyField = errors.New("table has no key field") // ErrKeyMissing is returned when key value is not set ErrKeyMissing = errors.New("key is not set") ErrNilWritePointers = errors.New("nil record dest members") )
Functions ¶
This section is empty.
Types ¶
type DBObject ¶
type DBObject interface {
// TableName is the name of the sql table
TableName() string
// KeyFields are the names of the table fields
// comprising the primary id
//KeyFields() []string
KeyField() string
// KeyNames are the struct names of the
// primary id fields
//KeyNames() []string
KeyName() string
// Names returns the struct element names
Names() []string
// SelectFields returns the comma separated
// list of fields to be selected
SelectFields() string
// InsertFields returns the comma separated
// list of fields to be selected
InsertFields() string
// Key returns the int64 id value of the object
Key() int64
// SetID updates the id of the object
SetID(int64)
// InsertValues returns the values of the object to be inserted
InsertValues() []interface{}
// InsertValues returns the values of the object to be updated
UpdateValues() []interface{}
// MemberPointers returns a slice of pointers to values
// for the db scan function
MemberPointers() []interface{}
// ModifiedBy returns the user id and timestamp of when the object was last modified
ModifiedBy(int64, time.Time)
}
DBObject provides methods for object storage The functions are generated for each object annotated accordingly
type DBS ¶
type DBS interface {
Query(fn SetHandler, query string, args ...interface{}) error
Exec(query string, args ...interface{}) (RowsAffected, LastInsertID int64, err error)
}
DBS is an abstracted database interface, intended to work with both rqlite and regular sql.DB connections
type DBU ¶
type DBU struct {
// contains filtered or unexported fields
}
DBU is a DatabaseUnit
func (DBU) DeleteByID ¶
DeleteByID object from datastore by id
type SetHandler ¶
type SetHandler func() []interface{}
SetHandler returns a slice of value pointer interfaces If there are no values to set it returns a nil instead
Directories
¶
| Path | Synopsis |
|---|---|
|
dbgen is a tool to automate the creation of create/update/delete methods that satisfy the github.com/paulstuart/dbobj.DBObject interface.
|
dbgen is a tool to automate the creation of create/update/delete methods that satisfy the github.com/paulstuart/dbobj.DBObject interface. |
Click to show internal directories.
Click to hide internal directories.