showing results for - "how to create alias in populate moongoose 2b nodejs"
Axel
06 Jan 2020
1var countrySchema = new mongoose.Schema({
2    capitalId: {type:String}
3});
4
5countrySchema.virtual('capital',{
6    ref: 'City',
7    localField: 'capitalId',
8    foreignField: '_id',
9    justOne: true
10});
11
12countrySchema.set('toObject', { virtuals: true });
13countrySchema.set('toJSON', { virtuals: true });