connect() Class
Item Index
Methods
- connect() static
Methods
connect()
(
Object
static
-
uri
Returns a MongoClient instance connected to the provided URI connection.
If a database is specified in the URI, a MongoDatabase is returned instead.
The format of the URI is:
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
For a detailed specification of the URI format, please check the java driver's MongoClientURI class
Parameters:
-
uri
StringURI to use for the connection
Returns:
Object:
returns
MongoClient
if no database was specified in the URI
otherwise returns the specified MongoDatabase
Example:
var client = mongo.connect('mongodb://localhost:27017');
var db = mongo.connect('mongodb://localhost/myDatabase');