Documentation ¶
Overview ¶
Package dba is an singleton that manages databases as would a Database Administrator.
Index ¶
- func AddMongoDB(m *MongoDB)
- func AddRedisDB(r *RedisDB)
- func AddSQL(s *SQL)
- func BSONID(id string) (bson.ObjectId, error)
- func GORP(name string) *gorp.DbMap
- func MGO(name string) *mgo.Database
- func RedisClient(db int64) *redis.Client
- type Database
- type DatabaseAdmin
- func (d *DatabaseAdmin) AddMongoDB(m *MongoDB)
- func (d *DatabaseAdmin) AddRedisDB(r *RedisDB)
- func (d *DatabaseAdmin) AddSQL(s *SQL)
- func (d *DatabaseAdmin) All() []Database
- func (d DatabaseAdmin) GORP(name string) *gorp.DbMap
- func (d DatabaseAdmin) MGO(name string) *mgo.Database
- func (d DatabaseAdmin) RedisClient(db int64) *redis.Client
- type MongoDB
- type RedisDB
- type SQL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMongoDB ¶
func AddMongoDB(m *MongoDB)
AddMongoDB adds a MongoDB database object to the db package.
func AddRedisDB ¶
func AddRedisDB(r *RedisDB)
AddRedisDB adds a Redis database client to the db package.
func AddSQL ¶
func AddSQL(s *SQL)
AddSQL adds a sql database object to the singleton DatabaseAdmin's databases.
func BSONID ¶
BSONID takes a string ID and converts it to a bson.ObjectId. If the string cannot be converted an error is returned.
func GORP ¶
func GORP(name string) *gorp.DbMap
GORP takes a database name to search all SQL databases the db package currently maintains and returns a pointer to a gorp.DbMap instance if found. gorp.DbMap represents an SQL orm-ish driver for multiple different SQL databases (sqlite, mysql, postgres). If no database is found nil is returned.
func MGO ¶
func MGO(name string) *mgo.Database
MGO takes a database name to search all mongodb databases the db package currently maintains and returns a pointer to a mgo.Database instance if found. mgo.Database represents a mongodb orm-ish driver for executing queries. If no database is found nil is returned.
func RedisClient ¶
func RedisClient(db int64) *redis.Client
RedisClient takes a database name to search all redis databases the db package currently maintains and returns a pointer to a redis.Client instance if found. redis.Client represents a RedisClient client for executing queries. If no database is found nil is returned.
Types ¶
type DatabaseAdmin ¶
DatabaseAdmin represents a database administrator object who's duty is to maintain all database values, connections, and state.
func (*DatabaseAdmin) AddMongoDB ¶
func (d *DatabaseAdmin) AddMongoDB(m *MongoDB)
AddMongoDB adds a MongoDB database object to the DatabaseAdmin databases.
func (*DatabaseAdmin) AddRedisDB ¶
func (d *DatabaseAdmin) AddRedisDB(r *RedisDB)
AddRedisDB adds a Redis database object to the DatabaseAdmin databases.
func (*DatabaseAdmin) AddSQL ¶
func (d *DatabaseAdmin) AddSQL(s *SQL)
AddSQL adds a sql database object to the DatabaseAdmin databases.
func (*DatabaseAdmin) All ¶
func (d *DatabaseAdmin) All() []Database
All returns all the databases this DatabaseAdmin maintains.
func (DatabaseAdmin) GORP ¶
func (d DatabaseAdmin) GORP(name string) *gorp.DbMap
GORP takes a database name to search all SQL databases DatabaseAdmin currently maintains and returns a pointer to a gorp.DbMap instance if found. gorp.DbMap represents an SQL orm-ish driver for multiple different SQL databases (sqlite, mysql, postgres). If no database is found nil is returned.
func (DatabaseAdmin) MGO ¶
func (d DatabaseAdmin) MGO(name string) *mgo.Database
MGO takes a database name to search all mongodb databases db.DBA currently maintains and returns a pointer to a mgo.Database instance if found. mgo.Database represents a mongodb orm-ish driver for executing queries. If no database is found nil is returned.
func (DatabaseAdmin) RedisClient ¶
func (d DatabaseAdmin) RedisClient(db int64) *redis.Client
RedisClient takes a database name to search all redis databases db.DBA currently maintains and returns a pointer to a redis.Client instance if found. redis.Client represents a redis driver for executing queries. If no database is found nil is returned.
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
MongoDB describes a mongodb database object.
func NewMongoDB ¶
NewMongoDB creates a new mongodb database object.
func (*MongoDB) Close ¶
func (m *MongoDB) Close()
Close satisfies the Database interface. The mongodb database object closes the connection the Dial method created.
type RedisDB ¶
type RedisDB struct {
// contains filtered or unexported fields
}
RedisDB describes a redis database object.
func (*RedisDB) Close ¶
func (r *RedisDB) Close()
Close satisfies the Database interface. The redis database object closes the connection the Dial method created.
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL describes an sql database object.
func (*SQL) Close ¶
func (s *SQL) Close()
Close satisfies the Database interface. The sql database object closes the connection the Dial method created.