Function connectMongoDB
If the host
/port
form is used, default settings will be used, which enable
safe updates, but no fsync. By specifying a URL instead, it is possible to
fully customize the settings. See
http://www.mongodb.org/display/DOCS/Connections for the complete set
of options.
Prototypes
MongoDB connectMongoDB( string host, ushort port ); MongoDB connectMongoDB( string host_or_url );
Examples
// connecting with default settings: auto db = connectMongoDB("127.0.0.1"); auto users = db["users"]; users.insert(Bson("peter"));
// connectiong using the URL form with custom settings auto db = connectMongoDB("mongodb://localhost/?slaveOk=true");
Parameters
Returns
A new MongoDB instance that can be used to access the database.
Throws
Throws an exception if a mongodb:// URL is given and the URL cannot be parsed.
An exception will not be thrown if called with a hostname and port
.
Authors
Sönke Ludwig
Copyright
© 2012 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.