59
I have 2 Schemas, Custphone and Subdomain. Custphone belongs_to a Subdomain and Subdomain has_many Custphones.
The problem is in creating the relationship using Mongoose. My goal is to do: custphone.subdomain and get the Subdomain that the Custphone belongs to.
I have this in my schemas:
SubdomainSchema = new Schema
name : String
CustphoneSchema = new Schema
phone : String
subdomain : [SubdomainSchema]
When I print the Custphone result I get this:
{ _id: 4e9bc59b01c642bf4a00002d,
subdomain: [] }
When the Custphone result has {"$oid": "4e9b532b01c642bf4a000003"} in MongoDB.
I want to do custphone.subdomain and get the subdomain object of the custphone.