发布于 2015-09-14 15:05:36 | 102 次阅读 | 评论: 0 | 来源: 网络整理

connect(<hostname>:<port>/<database>)

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")

也可以参考

Mongo.getDB()

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务