【发布时间】:2016-09-05 07:04:08
【问题描述】:
当我尝试删除集合时,Mongoose 会抛出错误,即“MongoError: ns not found”。
这是我的猫鼬代码:
var mongoose = require('bluebird').promisifyAll(require('mongoose'));
......
......
......
mongoose.connection.db.dropCollection("myCollection",function(err,affect){
console.log('err',err);
})
错误:
err { [MongoError: ns not found]
名称:'MongoError',
消息:'ns 没找到',
好的:0,
errmsg: 'ns 未找到' }
【问题讨论】:
-
你没有连接到数据库(使用
mongoose.connect())。 -
mongoose 没有 drop 收集方法。 chekout this 回答以获取更多信息。
-
是的,我用过 mongoose.connect()。 @robertklep
-
@RajeshDhiman,mongoose.connection.db.dropCollection 方法已经使用,stackoverflow.com/questions/11453617/…