参考链接
Opening New Connections
new Mongo()
new Mongo(<host>)
new Mongo(<host:port>)
conn = new Mongo();
db = conn.getDB("myDatabase");
db = connect("localhost:27020/myDatabase");
EXAMPLE
To print all items in a result cursor in mongo
shell scripts, use the following idiom:
cursor = db.collection.find();
while ( cursor.hasNext() ) {
printjson( cursor.next() );
}
Execute a JavaScript file
mongo localhost:27017/test myjsfile.js
load("myjstest.js")
The load()
method accepts relative and absolute paths. If the current working directory of the mongo
shell is /data/db
, and the myjstest.js
resides in the /data/db/scripts
directory, then the following calls within the mongo
shell would be equivalent:
load("scripts/myjstest.js")
load("/data/db/scripts/myjstest.js")
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于