Answer the question
In order to leave comments, you need to log in
How to organize relationships in Mongoose?
Here I have two models:
var PostSchema = new Schema({
title: String,
image: {
type: Schema.Types.ObjectId,
ref: 'Image'
},
content: String
});
var ImageSchema = new Schema({
url: String
});
{
"post":{
_id: // id,
title: //заголовок,
image: null,
content://контент
}
}
Answer the question
In order to leave comments, you need to log in
Can.
var PostSchema = new Schema({
title: String,
image: {
type: Schema.Types.ObjectId,
ref: 'Image',
default: null
},
content: String
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question