node.js - NodeJS Mongoose collection.remove not working -
trying drop docs in collections before unit tests run...
var collections = mongoose.connection.collections; async.eachseries(_.keys(collections), function(key, cb){ collections[key].remove(function(){ //never gets here, doesn't drop collection , doesn't error. cb(); }); }
but callback in remove() never gets fired. i've logged out collections[key]
, resolve collection.
no errors, times out never runs callback.
ive tried looping models , calling remove
same issue.
what doing wrong here?? logs at?
you try using drop method:
var async = require("async"), _ = require("underscore"), collections = _.keys(mongoose.connection.collections); async.foreach(collections, function(key, done) { var collection = mongoose.connection.collections[key] collection.drop(function(err) { if (err && err.message != "ns not found") { done(err); } else { done(null); } }) }, callback);
Comments
Post a Comment