Documentation ¶
Overview ¶
Package rqlobj provides basic object relational mapping against an sql(ite) database
Index ¶
- Variables
- type DBList
- type DBObject
- type RDB
- func (db RDB) Add(o DBObject) error
- func (db RDB) Debug(enable bool)
- func (db RDB) Delete(o DBObject) error
- func (db RDB) DeleteAll(o DBObject) error
- func (db RDB) DeleteByID(o DBObject, id int64) error
- func (db RDB) List(list DBList) error
- func (db RDB) ListQuery(list DBList, where string) error
- func (db RDB) Load(o DBObject, keys map[string]interface{}) error
- func (db RDB) LoadBy(o DBObject, key string, value interface{}) error
- func (db RDB) LoadByID(o DBObject, id int64) error
- func (db RDB) LoadSelf(o DBObject) error
- func (db RDB) SetLogger(w io.Writer)
- func (db RDB) Update(o DBObject) error
- func (db RDB) Write(queries ...string) ([]gorqlite.WriteResult, error)
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") // ErrNotFound is returned when query returns no rows ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type DBList ¶
type DBList interface { // SQLGet is the query string to retrieve the list SQLGet(extra string) string // SQLResults takes a Scan function SQLResults(func(...interface{}) error) error }
DBList is the interface for a list of db objects
type DBObject ¶
type DBObject interface { // TableName is the name of the sql table TableName() string // Primary returns the primary key and a bool, // set true, if the key is valid Primary() (int64, bool) // SetPrimary updates the primary key SetPrimary(int64) // KeyNames are the struct names of the // primary id fields KeyNames() []string // KeyValues returns the value(s) of the object key(s) KeyValues() []interface{} // KeyFields are the names of the table fields // comprising the primary id KeyFields() []string // Elements returns the struct element names Elements() []string // SelectFields returns the comma separated // list of fields to be selected SelectFields() string // InsertFields returns the comma separated // list of fields to be inserted InsertFields() string // InsertValues returns the values of the object to be inserted InsertValues() []interface{} // UpdateValues returns the values of the object to be updated UpdateValues() []interface{} // Receivers returns a slice of pointers to values // for the db Scan function Receivers() []interface{} // SQLCreate returns the string to create a table // representing the struct SQLCreate() string }
DBObject interface provides methods for object storage in an sql database. The functions are generated for each relevant struct type that are annotated accordingly TODO: consider namespacing these functions to avoid collision
type RDB ¶
type RDB struct {
// contains filtered or unexported fields
}
RDB is a database handler that works with DBOject variables
func (RDB) DeleteByID ¶
DeleteByID object from datastore by id
Directories ¶
Path | Synopsis |
---|---|
dbgen is a tool to automate the creation of CRUD methods (create/update/delete) that satisfy the DBObject interface in github.com/paulstuart/rqlobj.
|
dbgen is a tool to automate the creation of CRUD methods (create/update/delete) that satisfy the DBObject interface in github.com/paulstuart/rqlobj. |
Click to show internal directories.
Click to hide internal directories.