2012-02-20 12:32:46 +00:00
|
|
|
// The mgo ("mango") rich MongoDB driver for Go.
|
|
|
|
//
|
|
|
|
// The mgo project (pronounced as "mango") is a rich MongoDB driver for
|
2012-07-01 19:06:34 +00:00
|
|
|
// the Go language. High-level details about the project may be found
|
|
|
|
// at its web page:
|
2012-02-20 12:32:46 +00:00
|
|
|
//
|
|
|
|
// http://labix.org/mgo
|
|
|
|
//
|
|
|
|
// Usage of the driver revolves around the concept of sessions. To
|
2012-07-01 19:06:34 +00:00
|
|
|
// get started, obtain a session using the Dial function:
|
2012-02-20 12:32:46 +00:00
|
|
|
//
|
2012-07-01 19:06:34 +00:00
|
|
|
// session, err := mgo.Dial(url)
|
2012-02-20 12:32:46 +00:00
|
|
|
//
|
|
|
|
// This will establish one or more connections with the cluster of
|
|
|
|
// servers defined by the url parameter. From then on, the cluster
|
|
|
|
// may be queried with multiple consistency rules (see SetMode) and
|
2012-07-01 19:06:34 +00:00
|
|
|
// documents retrieved with statements such as:
|
2012-02-20 12:32:46 +00:00
|
|
|
//
|
|
|
|
// c := session.DB(database).C(collection)
|
|
|
|
// err := c.Find(query).One(&result)
|
|
|
|
//
|
|
|
|
// New sessions may be created by calling New, Copy, or Clone on an
|
|
|
|
// initial session. These spawned sessions will share the same cluster
|
2012-07-01 19:06:34 +00:00
|
|
|
// information and connection cache, and may be easily handed into other
|
2012-02-20 12:32:46 +00:00
|
|
|
// methods and functions for organizing logic. Every session created
|
|
|
|
// must have its Close method called at the end of its use.
|
|
|
|
//
|
|
|
|
// For more details, see the documentation for the types and methods.
|
|
|
|
//
|
|
|
|
package mgo
|