nestjs-paginate-mongo
v3.0.12
Published
<p align="center"> <a href="https://www.npmjs.com/package/nestjs-paginate-mongo"><img src="https://img.shields.io/npm/dm/nestjs-paginate-mongo.svg" alt="Total Downloads"></a> <a href="https://www.npmjs.com/package/nestjs-paginate-mongo"><img src="http
Downloads
346
Maintainers
Readme
Nestjs Paginate Mongo
A simple and fast way to paginate your mongoose query results on Nestjs
Requiements
- mongoose >= 8.0.0
How to use
To paginate items, you just need to call the function and pass the query as parameter. Just like this :
import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { paginate } from 'nestjs-paginate-mongo';
import { Post, PostDocument } from './entities/post.entity';
@Injectable()
export class PostsService {
constructor(
@InjectModel(Post.name) private readonly posts: Model<PostDocument>,
) {}
findAll() {
return paginate(this.posts.find());
}
}
And voila, you got your paginated data.
Contribution
- If you have any problem about this package or a suggestion, dont hesitate to inform me by creating an issue
- Are you a lovely developer and you think you can help by fixing a submitted issue ? Then I'll be glad to merge a PR from you 😊
Support me
Enjoying this little package ? You can support me 🙏