Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONIndent ¶
JSONIndent returns the stringified version of the giving data and indents its result. Uses json.Marshal underneath.
Types ¶
type Config ¶
type Config struct { DB string `toml:"db" json:"db"` AuthDB string `toml:"authdb" json:"authdb"` User string `toml:"user" json:"user"` Password string `toml:"password" json:"password"` Host string `toml:"host" json:"host"` }
Config embodies the data used to connect to user's mongo connection.
type MongoDB ¶
type MongoDB struct { Config // contains filtered or unexported fields }
MongoDB defines a mongo connection manager that builds allows usage of a giving configuration to generate new mongo sessions and database instances.
func NewMongoDB ¶
NewMongoDB returns a new instance of a MongoDB.
func (*MongoDB) New ¶
New returns a new session and database from the giving configuration.
Argument:
isread: bool
1. If `isread` is false, then the mgo.Session is cloned so that we re-use the existing sessiby not closing, so others get use ofn connection, in such case, it lets you optimize writes, so try not the session instance connection for other writes.
2. If `isread` is true, then session is copied which creates a new unique session which you should close after use, this lets you handle large reads that may contain complicated queries.
type MongoPull ¶
MongoPull implements a record pull mechanism which allows you to quickly pull records from the underline mongo collection which will be used for processing.