我想通过" id"从我的数据库搜索中检索整个模型。 在这种情况下哪种查询最好用?
这是我的架构的样子:
.Subscribe(...)
我所拥有的是:{ _id: 54b5ed4b967a4e3b96fe8a39,
email: 'blabla@yahoo.com',
__v: 0,
deleted: false,
createdAt: Tue Jan 13 2015 23:15:07 GMT-0500 (EST),
shipping: {},
profile: { picture: '', location: 'Romania', name: 'bla' },
tokens: [],
role: 'shopper'}
答案 0 :(得分:1)
如果您知道要查找的Model
类型,即Person
。只是做:
var id = "54b5ed4b967a4e3b96fe8a39";
Person.findById(id, function(err, person) {
if (err) {
return console.log('oh no! error', err);
}
console.log('found person', person);
});
文档here