0
這裏是我的代碼:刪除的所有文件MongoDB的原生
var environment = "ClientUnitTests";
//set up mongodb
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSetServers = require('mongodb').ReplSetServers,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Grid = require('mongodb').Grid,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
assert = require('assert');
var db = new Db('test',new Server('localhost',27017),{safe:true});
db.open(function(err, db) {
assert.equal(null, err);
});
var users = db.collection("users");
//Clean up data in test database for clientUnit tests
if (environment == "ClientUnitTests") {
users.remove({},function(err,numberRemoved){
console.log("inside remove call back" + numberRemoved);
});
}
基本上我想從我收集的用戶數據全部刪除時,應用程序在「ClientUnitTests」模式啓動。不幸的是,console.log語句從不會觸發(也可以通過設置一個從不觸發的斷點來驗證)。
什麼我做錯了這個集合中刪除所有文件?