On this page本页内容
connect
(url, user, password)¶Creates a connection to a MongoDB instance and returns the reference to the database. However, in most cases, use the Mongo()
object and its getDB()
method instead.
url |
string | Specifies the connection string. You can specify either:
|
user |
string | user is specified, you must include the password parameter as well. |
password |
string | Optional unless the user parameter is specified. Specifies the password for the user . |
The following example instantiates a new connection to the MongoDB instance running on the localhost interface and returns a reference to myDatabase
:
See also参阅