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
A pagination, filtering and sorting lib for nestjs using mongoose orm
npm install @forlagshuset/nestjs-mongoose-paginate
Typescript
Module System
Node Version
NPM Version
66.5
Supply Chain
94.3
Quality
82.2
Maintenance
100
Vulnerability
98.9
License
TypeScript (96.13%)
JavaScript (3.87%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
16 Stars
143 Commits
11 Forks
7 Watchers
21 Branches
14 Contributors
Updated on Feb 11, 2025
Latest Version
2.1.0
Package Id
@forlagshuset/nestjs-mongoose-paginate@2.1.0
Unpacked Size
134.93 kB
Size
24.47 kB
File Count
103
NPM Version
10.8.2
Node Version
20.18.2
Published on
Feb 11, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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 dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 8/18 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
7 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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 2025-07-07
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