From 518a3249126865a85bac812ff07f43cbdf5ee244 Mon Sep 17 00:00:00 2001 From: Wizek <123.wizek@gmail.com> Date: Wed, 6 Jun 2012 02:21:39 +0300 Subject: [PATCH] https://groups.google.com/d/msg/railwayjs/4YWICL6EAOg/ebCxGkQ5eQcJ --- lib/adapters/mongoose.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/adapters/mongoose.js b/lib/adapters/mongoose.js index 7e2181ae..231c515f 100644 --- a/lib/adapters/mongoose.js +++ b/lib/adapters/mongoose.js @@ -183,6 +183,7 @@ MongooseAdapter.prototype.destroyAll = function destroyAll(model, callback) { this._models[model].find(function (err, data) { if (err) return callback(err); wait = data.length; + if (!data.length) return callback(null); data.forEach(function (obj) { obj.remove(done) });