根据提供的信息,您似乎正在使用mongodb 2.0驱动程序。db.collectionNames方法已删除。查看此页面的“ Db对象”部分-https:
//github.com/mongodb/node-mongodb-
native/blob/0642f18fd85037522acf2e7560148a8bc5429a8a/docs/content/tutorials/changes-
from-1.0.md#L38
他们已将其替换为listCollections。您应该获得与以下相同的效果:
mongoose.connection.db.listCollections().toArray(function(err, names) { if (err) { console.log(err); } else { names.forEach(function(e,i,a) { mongoose.connection.db.dropCollection(e.name); console.log("--->>", e.name); }); }});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)