Documentation ¶
Index ¶
- func CloseMongoConn()
- func Connect(opts []*MongoConnOpts) (err error)
- func ConnectSingle(opts *MongoConnOpts) (err error)
- func Count(dtype string, filter *vcmn.Filter) (count int, err error)
- func Create(dtype string, value interface{}) (err error)
- func Delete(dtype string, matcher bson.M) (err error)
- func GenerateSelector(filter *vcmn.Filter) (selector bson.M)
- func Get(dtype string, matcher bson.M, out interface{}) (err error)
- func GetAll(dtype string, sortFiled string, offset int, limit int, filter *vcmn.Filter, ...) (err error)
- func GetAllWithCount(dtype string, sortFiled string, offset int, limit int, filter *vcmn.Filter, ...) (count int, err error)
- func GetCommands() (cmds []cli.Command)
- func GetFilterValues(dtype string, specs vcmn.FilterSpecList) (values bson.M, err error)
- func GetFilterValuesX(dtype string, field string, specs vcmn.FilterSpecList, filter *vcmn.Filter) (values bson.M, err error)
- func LogError(module string, err error) (out error)
- func MakeRequireMongo(cmd *cli.Command) *cli.Command
- func RegisterFactory(dataType string, ff FactoryFunc)
- func SetDefaultDB(defDB string)
- func Update(dtype string, matcher bson.M, value interface{}) (err error)
- type FactoryFunc
- type MongoConn
- type MongoConnOpts
- type StoredItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(opts []*MongoConnOpts) (err error)
Connect - connects to one or more mirrors of mongodb server
func ConnectSingle ¶
func ConnectSingle(opts *MongoConnOpts) (err error)
ConnectSingle - connects to single instance of mongodb server
func GenerateSelector ¶
GenerateSelector - creates mongodb query for a generic filter
func GetAll ¶
func GetAll(dtype string, sortFiled string, offset int, limit int, filter *vcmn.Filter, out interface{}) (err error)
GetAll - gets all the items from collection 'dtype' selected by filter & paged
func GetAllWithCount ¶
func GetAllWithCount(dtype string, sortFiled string, offset int, limit int, filter *vcmn.Filter, out interface{}) (count int, err error)
GetAllWithCount - gets all the items from collection 'dtype' selected by filter & paged also gives the total count of items selected by filter
func GetCommands ¶
func GetCommands() (cmds []cli.Command)
GetCommands - get list of commands for mongdb
func GetFilterValues ¶
GetFilterValues - provides values associated the fields defined in filter spec
func GetFilterValuesX ¶
func GetFilterValuesX( dtype string, field string, specs vcmn.FilterSpecList, filter *vcmn.Filter) (values bson.M, err error)
GetFilterValuesX - get values for filter based on given filter
func LogError ¶
LogError - if error is not mog.ErrNotFound return null otherwise log the error and return the given error
func MakeRequireMongo ¶
func MakeRequireMongo(cmd *cli.Command) *cli.Command
MakeRequireMongo - makes ccommand to require information that is needed to connect to a mongodb instance
func RegisterFactory ¶
func RegisterFactory(dataType string, ff FactoryFunc)
RegisterFactory - registers factory functions for a data type
Types ¶
type FactoryFunc ¶
type FactoryFunc func() StoredItem
FactoryFunc - Function for creating an instance of data type
type MongoConn ¶
MongoConn - represents a mongdb connection
func DefaultMongoConn ¶
func DefaultMongoConn() *MongoConn
DefaultMongoConn - creates a connection to default DB
func NewMongoConn ¶
NewMongoConn - creates a new connection to mogodb
type MongoConnOpts ¶
type MongoConnOpts struct { Host string `json:"host"` Port int `json:"port"` User string `json:"user"` Password string `json:"password"` }
MongoConnOpts - options for connecting to a mongodb instance
type StoredItem ¶
type StoredItem interface { ID() bson.ObjectId SetCreationInfo(at time.Time, by string) SetModInfo(at time.Time, by string) }
StoredItem - represents a value that is stored in database and is compatible with generic queries and handlers. Any struct with a need to support generic CRUD operations must implement and register a factory method to return it
func Instance ¶
func Instance(dataType string) StoredItem
Instance - creates and returns an instance of given data type