The connect() method creates a connection to a MongoDB instance. However, use the Mongo() object and its getDB() method in most cases.
connect() accepts a string <hostname>:<port>/<database> parameter to connect to the MongoDB instance on the <hostname>:<port> and return the reference to the database <database>.
The following example instantiates a new connection to the MongoDB instance running on the localhost interface and returns a reference to myDatabase:
db = connect("localhost:27017/myDatabase")
也可以参考