modulepackage
0.0.0-20181015135952-eeefdecb41b8
Repository: https://github.com/globalsign/mgo.git
Documentation: pkg.go.dev
# README
The MongoDB driver for Go
This fork has had a few improvements by ourselves as well as several PR's merged from the original mgo repo that are currently awaiting review. Changes are mostly geared towards performance improvements and bug fixes, though a few new features have been added.
Further PR's (with tests) are welcome, but please maintain backwards compatibility.
Detailed documentation of the API is available at GoDoc.
A sub-package that implements the BSON specification is also included, and may be used independently of the driver.
Supported Versions
mgo
is known to work well on (and has integration tests against) MongoDB v3.0, 3.2, 3.4 and 3.6.
MongoDB 4.0 is currently experimental - we would happily accept PRs to help improve support!
Changes
- Fixes attempting to authenticate before every query (details)
- Removes bulk update / delete batch size limitations (details)
- Adds native support for
time.Duration
marshalling (details) - Reduce memory footprint / garbage collection pressure by reusing buffers (details, more)
- Support majority read concerns (details)
- Improved connection handling (details)
- Hides SASL warnings (details)
- Support for partial indexes (details)
- Fixes timezone handling (details)
- Integration tests run against MongoDB 3.2 & 3.4 releases (details, more, more)
- Improved multi-document transaction performance (details, more, more)
- Fixes cursor timeouts (details)
- Support index hints and timeouts for count queries (details)
- Don't panic when handling indexed
int64
fields (details) - Supports dropping all indexes on a collection (details)
- Annotates log entries/profiler output with optional appName on 3.4+ (details)
- Support for read-only views in 3.4+ (details)
- Support for collations in 3.4+ (details, more)
- Provide BSON constants for convenience/sanity (details)
- Consistently unmarshal time.Time values as UTC (details)
- Enforces best practise coding guidelines (details)
- GetBSON correctly handles structs with both fields and pointers (details)
- Improved bson.Raw unmarshalling performance (details)
- Minimise socket connection timeouts due to excessive locking (details)
- Natively support X509 client authentication (details)
- Gracefully recover from a temporarily unreachable server (details)
- Use JSON tags when no explicit BSON are tags set (details)
- Support $changeStream tailing on 3.6+ (details)
- Fix deadlock in cluster synchronisation (details)
- Implement
maxIdleTimeout
for pooled connections (details) - Connection pool waiting improvements (details)
- Fixes BSON encoding for
$in
and friends (details) - Add BSON stream encoders (details)
- Add integer map key support in the BSON encoder (details)
- Support aggregation collations (details)
- Support encoding of inline struct references (details)
- Improved windows test harness (details)
- Improved type and nil handling in the BSON codec (details, more)
- Separated network read/write timeouts (details)
- Expanded dial string configuration options (details)
- Implement MongoTimestamp (details)
- Support setting
writeConcern
forfindAndModify
operations (details) - Add
ssl
to the dial string options (details)
Thanks to
- @aksentyev
- @bachue
- @bozaro
- @BenLubar
- @carldunham
- @carter2000
- @cedric-cordenier
- @cezarsa
- @DaytonG
- @ddspog
- @drichelson
- @dvic
- @eaglerayp
- @feliixx
- @fmpwizard
- @gazoon
- @gedge
- @gnawux
- @idy
- @jameinel
- @jefferickson
- @johnlawsharrison
- @KJTsanaktsidis
- @larrycinnabar
- @mapete94
- @maxnoel
- @mcspring
- @Mei-Zhao
- @peterdeka
- @Reenjii
- @roobre
- @smoya
- @steve-gray
- @tbruyelle
- @wgallagher
# Packages
Package bson is an implementation of the BSON specification for Go:
http://bsonspec.org
It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
No description provided by the author
Package txn implements support for multi-document transactions.
# Functions
Dial establishes a new session to the cluster identified by the given seed server(s).
DialWithInfo establishes a new session to the cluster identified by info.
DialWithTimeout works like Dial, but uses timeout as the amount of time to wait for a server to respond when first connecting and also on follow up operations in the session.
GetStats return the current database state.
IsDup returns whether err informs of a duplicate key error because a primary key index or a secondary unique index already has an entry with the given value.
ParseURL parses a MongoDB URL as accepted by the Dial function and returns a value suitable for providing into DialWithInfo.
ResetStats reset Stats to the previous database state.
SetDebug enable the delivery of debug messages to the logger.
SetLogger specify the *log.Logger object where log messages should be sent to.
SetStats enable database state monitoring.
# Constants
No description provided by the author
DefaultConnectionPoolLimit defines the default maximum number of connections in the connection pool.
Eventual mode is specific to mgo, and is same as Nearest, but may change servers between reads.
Monotonic mode is specifc to mgo, and is same as SecondaryPreferred before first write.
Nearest mode: read from one of the nearest members, irrespective of it being primary or secondary.
Primary mode is default mode.
PrimaryPreferred mode: read from the primary if available.
RoleClusterAdmin Provides the greatest cluster-management access.
RoleDBAdmin provides all the privileges of the dbAdmin role on a specific database.
RoleDBAdminAny provides all the privileges of the dbAdmin role on all databases.
RoleRead provides the ability to read data on all non-system collections and on the following system collections: system.indexes, system.js, and system.namespaces collections on a specific database.
RoleReadAny provides the same read-only permissions as read, except it applies to it applies to all but the local and config databases in the cluster.
RoleReadWrite provides all the privileges of the read role plus ability to modify data onall non-system collections and the system.js collection on a specific database.
RoleReadWriteAny provides the same read and write permissions as readWrite, except it applies to all but the local and config databases in the cluster.
RoleRoot provides access to the operations and all the resources of the readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase, clusterAdmin roles, restore, and backup roles combined.
RoleUserAdmin Provides the ability to create and modify roles and users on the current database.
RoleUserAdminAny provides the same access to user administration operations as userAdmin, except it applies to all but the local and config databases in the cluster.
Secondary mode: read from one of the nearest secondary members of the replica set.
SecondaryPreferred mode: read from one of the nearest secondaries if available.
Strong mode is specific to mgo, and is same as Primary.
No description provided by the author
# Variables
ErrCursor error returned when trying to retrieve documents from an invalid cursor.
ErrNotFound error returned when a document could not be found.
# Structs
The BuildInfo type encapsulates details about the running MongoDB server.
Bulk represents an operation that can be prepared with several orthogonal changes before being delivered to the server.
BulkError holds an error returned from running a Bulk operation.
BulkErrorCase holds an individual error found while attempting a single change within a bulk operation, and the position in which it was enqueued.
BulkResult holds the results for a bulk operation.
Change holds fields for running a findAndModify MongoDB command via the Query.Apply method.
ChangeInfo holds details about the outcome of an update operation.
No description provided by the author
No description provided by the author
Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.
Collection stores documents
Relevant documentation:
https://docs.mongodb.com/manual/core/databases-and-collections/#collections
.
The CollectionInfo type holds metadata about a collection.
Credential holds details to authenticate with a MongoDB server.
Database holds collections of documents
Relevant documentation:
https://docs.mongodb.com/manual/core/databases-and-collections/#databases
.
The DBRef type implements support for the database reference MongoDB convention as supported by multiple drivers.
DialInfo holds options for establishing a session with a MongoDB cluster.
GridFile document in files collection.
GridFS stores files in two collections:
- chunks stores the binary chunks.
Index are special data structures that store a small portion of the collection’s data set in an easy to traverse form.
Iter stores informations about a Cursor
Relevant documentation:
https://docs.mongodb.com/manual/tutorial/iterate-a-cursor/
.
LastError the error status of the preceding write operation on the current connection.
MapReduce used to perform Map Reduce operations
Relevant documentation:
https://docs.mongodb.com/manual/core/map-reduce/
.
MapReduceInfo stores informations on a MapReduce operation.
MapReduceTime stores execution time of a MapReduce operation.
Pipe is used to run aggregation queries against a collection.
Query keeps info on the query.
QueryError is returned when a query fails.
ReadPreference defines the manner in which servers are chosen.
Safe session safety mode.
ServerAddr represents the address for establishing a connection to an individual MongoDB server.
Session represents a communication session with the database.
Stats holds info on the database state
Relevant documentation:
https://docs.mongodb.com/manual/reference/command/serverStatus/
TODO outdated fields ?.
User represents a MongoDB user.
# Type aliases
No description provided by the author
Mode read preference mode.
Role available role for users
Relevant documentation:
http://docs.mongodb.org/manual/reference/user-privileges/
.