У меня есть 2 схемы, Custphone
и Subdomain
. Custphone
belongs_to
a Subdomain
и Subdomain
has_many
Custphones
.
Проблема заключается в создании отношений с использованием Mongoose. Моя цель - сделать custphone.subdomain и получить субдомен, к которому принадлежит Custphone.
У меня это в моих схемах:
SubdomainSchema = new Schema
name : String
CustphoneSchema = new Schema
phone : String
subdomain : [SubdomainSchema]
Когда я печатаю результат Custphone, я получаю следующее:
{ _id: 4e9bc59b01c642bf4a00002d,
subdomain: [] }
Когда результат Custphone
имеет {"$oid": "4e9b532b01c642bf4a000003"}
в MongoDB.
Я хочу сделать custphone.subdomain
и получить объект субдомена custphone.