发布于 2015-09-14 15:05:36 | 102 次阅读 | 评论: 0 | 来源: 网络整理
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")
也可以参考