Reputation: 2463
I have a users model with a ref to company. My data is as follows:
{
"name":"justin",
"notes":"hello notes",
"company":
{"name":"acme inc"}
}
Is it possible to save my data as a single call or would I need to save my company model first, then save my user afterward?
var UserSchema = new Schema({
name: {
type: String,
trim: true,
default: ''
},
notes:{
type:String
},
company: {
type: Schema.ObjectId,
ref: 'Company'
})
Upvotes: 1
Views: 90
Reputation: 964
In a NoSQL database everything is document oriented so you wouldn't typically do what you are trying to do. You will need to manage the "foreign key" relationship yourself, in code.
Upvotes: 1