Answers for "how to create alias in populate moongoose + nodejs"

0

how to create alias in populate moongoose + nodejs

var countrySchema = new mongoose.Schema({
    capitalId: {type:String}
});

countrySchema.virtual('capital',{
    ref: 'City',
    localField: 'capitalId',
    foreignField: '_id',
    justOne: true
});

countrySchema.set('toObject', { virtuals: true });
countrySchema.set('toJSON', { virtuals: true });
Posted by: Guest on December-21-2020

Code answers related to "how to create alias in populate moongoose + nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language