【发布时间】:2011-12-10 07:32:54
【问题描述】:
假设我有Subdomain ID,我是否需要进行查找才能获得子域对象?
例如:我必须做Subdomain.find {_id: item.subdomain_id}, (err, subdomain) -> 才能获得对象子域?最好只做item.subdomain。
谢谢!
【问题讨论】:
标签: mongodb node.js coffeescript mongoose
假设我有Subdomain ID,我是否需要进行查找才能获得子域对象?
例如:我必须做Subdomain.find {_id: item.subdomain_id}, (err, subdomain) -> 才能获得对象子域?最好只做item.subdomain。
谢谢!
【问题讨论】:
标签: mongodb node.js coffeescript mongoose
如果您只有 _id,您仍然需要查找文档本身。在 Mongoose 中,这可以使用 Model.findById 来完成,如下所述:http://mongoosejs.com/docs/finding-documents.html#Model.findById
【讨论】: