【发布时间】:2011-12-10 06:52:37
【问题描述】:
我有 2 个架构,Custphone 和 Subdomain。 Custphonebelongs_toSubdomain和Subdomainhas_manyCustphones。
问题在于使用 Mongoose 创建关系。我的目标是: custphone.subdomain 并获取 Custphone 所属的子域。
我的架构中有这个:
SubdomainSchema = new Schema
name : String
CustphoneSchema = new Schema
phone : String
subdomain : [SubdomainSchema]
当我打印 Custphone 结果时,我得到:
{ _id: 4e9bc59b01c642bf4a00002d,
subdomain: [] }
当 Custphone 结果在 MongoDB 中有 {"$oid": "4e9b532b01c642bf4a000003"} 时。
我想做custphone.subdomain并获取custphone的子域对象。
【问题讨论】:
-
@Mike Robinson - 我想做 custphone.subdomain 并获取 custphone 的子域对象。
标签: javascript mongodb node.js mongoose