github.com/lianghucheng/zrddz@v0.0.0-20200923083010-c71f680932e2/src/gopkg.in/mgo.v2/doc.go (about)

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