referring to Mongoose url populate example given at https://mongoosejs.com/docs/populate.html#checking-populated , there seems to be a two way relationship between both Schema. What if I only have 1 way relationship for example ( using same schema example, But Person schema does not Story ref )
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const personSchema = Schema({
name: String,
age: Number
});
const storySchema = Schema({
author: { type: Schema.Types.ObjectId, ref: 'Person' },
title: String
});
const Story = mongoose.model('Story', storySchema);
const Person = mongoose.model('Person', personSchema);
How can I return a GET Story output that looks like the following :
{
author :{
name: "Bla bla bla",
age: 30
}
title : "ABC Story"
}
I am always getting this at the moment :
{
author :34235245453
title : "ABC Story"
}