Open uncledent opened 6 years ago
If you need just the mongoose plugin which will use your mongoose model, you can try this lib: https://github.com/uncledent/mongoose-cursor-pagination-plugin
It is fully based on this library, but there is the mongoose plugin only, other stuff is removed. It uses mongoose model instead of raw mongo driver.
I have tried your plugin but I face another problem. When I use with nestjs, I have to declare the model while injecting:
@InjectModel('Item') private ItemModel: PaginateModel<Item>
In your plugin there is no PaginateModel so the nest can not work, do you have another solution for this? I really need to make the virtual works.
@sangdth You can just create an interface by your own and use it:
export interface PaginatedModel<T extends Document> extends Model<T> {
paginate(paginantionOptions: any): PaginationResult<T>;
}
It ignores virtuals and hidden fields with { select: false }.
Does anyone know a workaround for that?