mongoose-paginate-v2
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -16,2 +16,18 @@ module.exports = { | ||
}, | ||
overrides: [ | ||
{ | ||
files: '**/*.{ts,tsx}', | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
], | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/ban-types': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
# Changelog | ||
## v1.6.0 | ||
[2022-02-03] | ||
- Added Typescript version. | ||
## v1.5.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "mongoose-paginate-v2", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "A custom pagination library for Mongoose with customizable labels.", | ||
"main": "dist/index.js", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
@@ -57,3 +58,2 @@ "pretest": "npm run build", | ||
"homepage": "https://github.com/aravindnc/mongoose-paginate-v2#readme", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -79,5 +79,7 @@ "@babel/cli": "^7.14.5", | ||
"@babel/preset-env": "^7.14.7", | ||
"@typescript-eslint/eslint-plugin": "^5.10.2", | ||
"@typescript-eslint/parser": "^5.10.2", | ||
"babel-eslint": "^10.1.0", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.30.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
@@ -88,3 +90,4 @@ "husky": "^4.3.8", | ||
"mongoose": "^5.13.2", | ||
"prettier": "^2.3.2" | ||
"prettier": "^2.3.2", | ||
"typescript": "^4.5.5" | ||
}, | ||
@@ -91,0 +94,0 @@ "engines": { |
@@ -48,2 +48,27 @@ ![Banner](static/banner.jpg) | ||
### Typescript | ||
Prior to version `1.5.0`, types need to be installed from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mongoose-paginate-v2). | ||
To declare a `PaginateModel` in your Typescript files: | ||
```ts | ||
import paginate from 'mongoose-paginate-v2'; | ||
// declare your schema | ||
export const institutionSchema = new Schema({ name: String }); | ||
// paginate with this plugin | ||
institutionSchema.plugin(paginate); | ||
// declare a mongoose document based on a Typescript interface representing your schema | ||
interface InstitutionDocument extends Document, InstitutionData {} | ||
// create the paginated model | ||
const model = mongoose.model< | ||
InstitutionDocument, | ||
PaginateModel<InstitutionDocument> | ||
>('Institutions', institutionSchema, 'institutions'); | ||
``` | ||
### Model.paginate([query], [options], [callback]) | ||
@@ -50,0 +75,0 @@ |
311209
21
1522
426
31