Gathering detailed insights and metrics for @forlagshuset/nestjs-mongoose-paginate
Gathering detailed insights and metrics for @forlagshuset/nestjs-mongoose-paginate
Gathering detailed insights and metrics for @forlagshuset/nestjs-mongoose-paginate
Gathering detailed insights and metrics for @forlagshuset/nestjs-mongoose-paginate
mongoose-paginate-v2
A custom pagination library for Mongoose with customizable labels.
mongoose-aggregate-paginate-v2
A cursor based custom aggregate pagination library for Mongoose with customizable labels.
nestjs-typeorm-paginate
A simple pagination function to build a pagination object with types
nestjs-paginate
Pagination and filtering helper method for TypeORM repositories or query builders using Nest.js framework.
npm install @forlagshuset/nestjs-mongoose-paginate
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
16 Stars
134 Commits
10 Forks
7 Watching
21 Branches
10 Contributors
Updated on 08 Oct 2024
TypeScript (96%)
JavaScript (4%)
Cumulative downloads
Total Downloads
Last day
114%
122
Compared to previous day
Last week
16.7%
371
Compared to previous week
Last month
-5.7%
1,563
Compared to previous month
Last year
47.4%
16,990
Compared to previous year
8
A pagination, filtering and sorting lib for nestjs v8(for v7 please use < v1.1) using mongoose orm
Create a class to hold information about filterable and sortable properties
You need to @Expose
properties of this class. By default none of it is filterable nor sortable.
You should set this parameters explicitly.
In case you want to expose some of the properties with a different name, you need to specify a name
option in this decorator.
1import { 2 CollectionProperties, 3 Expose 4} from '@forlagshuset/nestjs-mongoose-paginate'; 5 6export class MyCollectionProperties extends CollectionProperties { 7 @Expose({ name: 'createdAt', sortable: true }) 8 readonly created_at: 'desc' | 'asc'; 9 10 @Expose({ sortable: true, default: true, filterable: true }) 11 readonly userName: 'desc' | 'asc'; 12 13 readonly unsortable: string; 14}
1import { 2 CollectionDto, 3 ValidationPipe, 4 CollectionResponse 5} from '@forlagshuset/nestjs-mongoose-paginate'; 6 7@Controller() 8export class AppController { 9 @Get('list') 10 async filter( 11 @Query(new ValidationPipe(MyCollectionProperties)) 12 collectionDto: CollectionDto, 13 ): Promise<CollectionResponse<MyDocument>> { 14 return await this.service.list(collectionDto); 15 } 16}
1import { Model } from 'mongoose'; 2import { InjectModel } from '@nestjs/mongoose'; 3import { 4 CollectionDto, 5 DocumentCollector, 6 CollectionResponse 7} from '@forlagshuset/nestjs-mongoose-paginate'; 8 9@Injectable() 10export class AppService { 11 constructor( 12 @InjectModel('MyModel') private readonly model: Model<MyDocument>, 13 ) 14 15 async list( 16 collectionDto: CollectionDto, 17 ): Promise<CollectionResponse<MyDocument>> { 18 const collector = new DocumentCollector<MyDocument>(this.model); 19 return collector.find(collectionDto); 20 } 21}
You may now send a request, like in example below:
http://localhost:3000/list?filter={"userName": {"$regex": "^test"}}&sort=-createdAt&page=0&limit=100
You need to run the parameters through urlencode
to be able to parse the query correctly. So the filter part looks more like
%7B%22userName%22%3A%20%7B%22%24regex%22%3A%20%22%5Etest%22%7D%7D
You can specify more than one field for sorting by providing a list of them separated by a semicolon: createdAt;userName
.
To use DESC sort order: -createdAt
.
A subset of mongoose query language is supported. Currently only these operators are supported:
'$eq', '$gt', '$gte', '$in', '$lt', '$lte', '$ne', '$nin', '$and', '$not', '$nor', '$or', '$regex'
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
3 existing vulnerabilities detected
Details
Reason
Found 8/17 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More