var id = new mongodb.ObjectID("545e2fa90293a69004414ae9");
User.findById(id, function(err, user) {});
身份证value = "T^/©¦AJé"
?为什么?
请帮帮我!
对我来说mongodb
,您的代码毫无意义。您需要的是mongoose
,在您的代码中将它与表单的声明一起带入var mongoose = require('mongoose');
。
特别是,这是 mongoose 对预期 id: here的描述。
我的观点是,ObjectID 是这样实现的:
var id = new mongoose.Types.ObjectId('545e2fa90293a69004414ae9');
console.log('the id is: ' + id);
现在您可以在控制台上看到预期的字符串(但正如前面提到ObejectId
的,它不是字符串;它是一个对象,您可以通过typeof
操作员轻松验证。)。
这就是为什么我不确定您的代码中的mongodb.ObjectId('....');
.