MongoDB官方提供的Node.js的驅動包

fmms 12年前發布 | 27K 次閱讀 MongoDB NoSQL數據庫

這是 MongoDB 官方提供的 Node.js 的驅動包,示例代碼:

var client = new Db('test', new Server("127.0.0.1", 27017, {})),
    test = function (err, collection) {
      collection.insert({a:2}, function(err, docs) {

    collection.count(function(err, count) {
      test.assertEquals(1, count);
    });

    // Locate all the entries using find
    collection.find().toArray(function(err, results) {
      test.assertEquals(1, results.length);
      test.assertTrue(results[0].a === 2);

      // Let's close the db
      client.close();
    });
  });
};

client.open(function(err, p_client) { client.collection('test_insert', test); });</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1335795622124

 本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!