mongoose-paginate
mongoose-paginate copied to clipboard
Support for virtual field
I have a virtual field on my modal but it does not show up after I paginate.
Maybe that's not super efficient but you can always do this to get virtuals. Keep in mind you have to set virtuals: true in the Schema toObject option.
Schema.paginate({}, { limit: 5 }).then(result => {
for (let index in result.docs) {
result.docs[index] = result.docs[index].toObject();
}
return result;
});
in yours schema definition, set options like :
{
toJSON: { virtuals: true }
}
in yours schema definition, set options like :
{ toJSON: { virtuals: true } }
Thank you bro, saved my life :)