2015-05-31 87 views

回答

3

發現:

http://mongodb.github.io/node-mongodb-native/2.0/api/Db.html#db

這裏是他們例如

var MongoClient = require('mongodb').MongoClient, 
    test = require('assert'); 
MongoClient.connect('mongodb://localhost:27017/test', function(err, db) { 
    test.equal(null, err); 

    // Reference a different database sharing the same connections 
    // for the data transfer 
    var secondDb = db.db("integration_tests_2"); 
    ... 

它是同步的。對我來說似乎很奇怪,這種方法沒有「使用」一詞。也似乎奇怪它屬於db類。 db.db('other_db') ..有點模糊。做了一些測試,似乎有效,所以我會將這標記爲最終結果的其他人的答案。

相關問題