When I try to populate it does even save the document when I put population option. See example below,
const mongoosastic = require('mongoosastic');
const companyModel = require('./CompanyModel.js');
var Schema = mongoose.Schema;
var UserSchema = new Schema({
Public: {
fullName: {type: String, es_indexed: true},
email: String,
company: {
type: mongoose.Schema.Types.ObjectId,
ref: 'company',
es_schema: companyModel, es_indexed:true, es_select: 'Info.CompanyName Info.CompanyLogo'
}
}
});
UserSchema.plugin(mongoosastic, {
populate: [
{ path: 'Public.company', select: 'Info.CompanyName Info.CompanyLogo'}
]
})
var UserModel = mongoose.model('user', UserSchema);
module.exports = UserModel;
Can anybody help me with mongoostatic population feature. I have reffered this feature from the below link: https://github.com/mongoosastic/mongoosastic#indexing-mongoose-references
via Elvin Mammadov
No comments:
Post a Comment