【问题标题】:Node.js - Get the SchemaObject without querying?Node.js - 无需查询即可获取 SchemaObject?
【发布时间】:2011-12-10 07:32:54
【问题描述】:

假设我有Subdomain ID,我是否需要进行查找才能获得子域对象?

例如:我必须做Subdomain.find {_id: item.subdomain_id}, (err, subdomain) -> 才能获得对象子域?最好只做item.subdomain

谢谢!

【问题讨论】:

标签: mongodb node.js coffeescript mongoose


【解决方案1】:

如果您只有 _id,您仍然需要查找文档本身。在 Mongoose 中,这可以使用 Model.findById 来完成,如下所述:http://mongoosejs.com/docs/finding-documents.html#Model.findById

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 2015-11-10
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    相关资源
    最近更新 更多