# README
db
import "github.com/coralproject/shelf/internal/platform/db"
Overview
Package db abstracts different database systems we can use.
Index
- Variables
- func RegMasterSession(context interface{}, name string, url string, timeout time.Duration) error
- type DB
- func NewMGO(context interface{}, name string) (*DB, error)
- func (db *DB) BatchedQueryMGO(context interface{}, colName string, q bson.M) (*mgo.Iter, error)
- func (db *DB) BulkOperationMGO(context interface{}, colName string) (*mgo.Bulk, error)
- func (db *DB) CloseCayley(context interface{})
- func (db *DB) CloseMGO(context interface{})
- func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)
- func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)
- func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error
- func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error
- func (db *DB) GraphHandle(context interface{}) (*cayley.Handle, error)
- func (db *DB) NewCayley(context interface{}, name string) error
Package files
Variables
var ErrGraphHandle = errors.New("Graph handle not initialized.")
ErrGraphHandle is returned when a graph handle is not initialized.
var ErrInvalidDBProvided = errors.New("Invalid DB provided")
ErrInvalidDBProvided is returned in the event that an uninitialized db is used to perform actions against.
func RegMasterSession
func RegMasterSession(context interface{}, name string, url string, timeout time.Duration) error
RegMasterSession adds a new master session to the set. If no url is provided, it will default to localhost:27017.
type DB
type DB struct {
// contains filtered or unexported fields
}
DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.
func NewMGO
func NewMGO(context interface{}, name string) (*DB, error)
NewMGO returns a new DB value for use with MongoDB based on a registered master session.
func (*DB) BatchedQueryMGO
func (db *DB) BatchedQueryMGO(context interface{}, colName string, q bson.M) (*mgo.Iter, error)
BatchedQueryMGO returns an iterator capable of iterating over all the results of a query in batches.
func (*DB) BulkOperationMGO
func (db *DB) BulkOperationMGO(context interface{}, colName string) (*mgo.Bulk, error)
BulkOperationMGO returns a bulk value that allows multiple orthogonal changes to be delivered to the server.
func (*DB) CloseCayley
func (db *DB) CloseCayley(context interface{})
CloseCayley closes a graph handle value.
func (*DB) CloseMGO
func (db *DB) CloseMGO(context interface{})
CloseMGO closes a DB value being used with MongoDB.
func (*DB) CollectionMGO
func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)
CollectionMGO is used to get a collection value.
func (*DB) CollectionMGOTimeout
func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)
CollectionMGOTimeout is used to get a collection value with a timeout.
func (*DB) ExecuteMGO
func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error
ExecuteMGO is used to execute MongoDB commands.
func (*DB) ExecuteMGOTimeout
func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error
ExecuteMGOTimeout is used to execute MongoDB commands with a timeout.
func (*DB) GraphHandle
func (db *DB) GraphHandle(context interface{}) (*cayley.Handle, error)
GraphHandle returns the Cayley graph handle for graph interactions.
func (*DB) NewCayley
func (db *DB) NewCayley(context interface{}, name string) error
NewCayley adds support to a DB value for cayley based on a registered master cayley handle.
Generated by godoc2md