Documentation ¶
Overview ¶
Package ivy provides a simple, file-based Database Management System (DBMS) that can be used in Go programs.
Index ¶
- type DB
- func (db *DB) Close()
- func (db *DB) Create(tblName string, rec interface{}) (string, error)
- func (db *DB) Delete(tblName string, fileId string) error
- func (db *DB) Find(tblName string, rec Record, fileId string) error
- func (db *DB) FindAllIds(tblName string) ([]string, error)
- func (db *DB) FindAllIdsForField(tblName string, searchField string, searchValue string) ([]string, error)
- func (db *DB) FindAllIdsForTags(tblName string, searchTags []string) ([]string, error)
- func (db *DB) FindFirstIdForField(tblName string, searchField string, searchValue string) (string, error)
- func (db *DB) Update(tblName string, rec interface{}, fileId string) error
- type Record
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
Type DB is a struct representing the database connection.
func OpenDB ¶
OpenDB initializes an ivy database. It returns a pointer to a DB struct and any error encountered.
func (*DB) Create ¶
Create creates a new record for the specified table. It takes a table name, and a struct representing the record data. It returns the id of the newly created record and any error encountered.
func (*DB) Delete ¶
Delete deletes a record for the specified table. It takes a table name and the record id of the record to be deleted.. It returns any error encountered.
func (*DB) Find ¶
Find loads up a Record struct with the record corresponding to a supplied id. It takes a table name, a pointer to a Record struct, and an id specifying the record to find. It populates the Record struct attributes with values from the found record. It returns any error encountered.
func (*DB) FindAllIds ¶
FindAllIds return all ids for the specified table name. It takes a table name. It returns a slice of ids and any error encountered.
func (*DB) FindAllIdsForField ¶
func (db *DB) FindAllIdsForField(tblName string, searchField string, searchValue string) ([]string, error)
FindAllIdsForField returns all record ids that match the supplied search criteria. It takes a table name, a field name to search on, and a value to search for. It returns a slice of record ids and any error encountered.
func (*DB) FindAllIdsForTags ¶
FindAllIdsForTag returns all record ids that match the all of the supplied search tags. It takes a table name, and a slice of tags to search for. It returns a slice of record ids and any error encountered.
func (*DB) FindFirstIdForField ¶
func (db *DB) FindFirstIdForField(tblName string, searchField string, searchValue string) (string, error)
FindFirstIdForField returns the first record id that matches the supplied search criteria. It takes a table name, a field name to search on, and a value to search for. It returns a record id and any error encountered.
type Record ¶
Type Record is an interface that your table model needs to implement. The AfterFind method is a callback that will run inside the Find method, right after the record is found and populated. This method will be passed the database connection and the record id of the record just found. In your implementation of this method, you should convert the record interface back to it's original type. Take a look at example.go in the examples directory for a look at how to do this.