doc.go 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Package mgo offers a rich MongoDB driver for Go.
  2. //
  3. // Details about the mgo project (pronounced as "mango") are found
  4. // in its web page:
  5. //
  6. // http://labix.org/mgo
  7. //
  8. // Usage of the driver revolves around the concept of sessions. To
  9. // get started, obtain a session using the Dial function:
  10. //
  11. // session, err := mgo.Dial(url)
  12. //
  13. // This will establish one or more connections with the cluster of
  14. // servers defined by the url parameter. From then on, the cluster
  15. // may be queried with multiple consistency rules (see SetMode) and
  16. // documents retrieved with statements such as:
  17. //
  18. // c := session.DB(database).C(collection)
  19. // err := c.Find(query).One(&result)
  20. //
  21. // New sessions are typically created by calling session.Copy on the
  22. // initial session obtained at dial time. These new sessions will share
  23. // the same cluster information and connection pool, and may be easily
  24. // handed into other methods and functions for organizing logic.
  25. // Every session created must have its Close method called at the end
  26. // of its life time, so its resources may be put back in the pool or
  27. // collected, depending on the case.
  28. //
  29. // For more details, see the documentation for the types and methods.
  30. //
  31. package mgo