collection is a master collection
var FeedsSchema = new mongoose.Schema({
categoryName: {
type: String,
unique: true,
required: true,
ref: 'feeds',
trim: true
},
categoryLogo: {
type: String,
unique: false,
required: true,
trim: true
},
status:{
type: String,
required: true,
},
date:{
type: String,
required:true
}
});
var categories = mongoose.model('categories', FeedsSchema);
module.exports = categories;
collection is a children collection
var UserSchema = new mongoose.Schema({
user_id: {
type: String,
ref: 'user',
required: true,
trim: true
},
preferences :{
type: String,
required: true,
ref: 'categories',
trim: true
},
status :{
type: String,
required: true,
trim: true
}
});
var Preferences = mongoose.model('preferences', UserSchema);
module.exports = Preferences;
Requires to show all the values from master collection & a field related needs to be pushed in the main to show it's in 2nd collection please suggest the relevant method to implement that