标签:mongod 默认 method sep show try cti 本地登录 his
接手一个很老的项目 数据库用的mongodb
代码里的collections表名用的auth没问题
直接去monogdb show table
确实有auth表
想在本地登录,看看用户信息
> db.auth.findOne()
Thu Sep 21 14:26:03.829 TypeError: Object function () {
var ex;
try {
this._authOrThrow.apply(this, arguments);
} catch (ex) {
print(ex);
return 0;
}
return 1;
} has no method ‘findOne‘
怪了就
然后看看
> db.auth
function () {
var ex;
try {
this._authOrThrow.apply(this, arguments);
} catch (ex) {
print(ex);
return 0;
}
return 1;
}
什么鬼,怎么都想不通,这版本mongo太老了,我以为是mongo的权限有什么问题 addUser,createUser绕了一圈
但代码里的表名明明就是auth
库里怎么就成了function
突然想到,auth不是mongo自带的方法么
db.getCollection("auth").findOne()
果然看到数据了
代码mongo driver里默认用的getCollection("auth") 能拿到数据
shell里我个人习惯直接db.tbname 表名和原生方法名相同,成了调用auth方法
就和不论什么语言编程不用保留字一样,不管用什么db,不要原生的方法名和关键字当表名,这是常识
标签:mongod 默认 method sep show try cti 本地登录 his
原文地址:http://www.cnblogs.com/zihunqingxin/p/7658521.html