Skip to content

Commit 2259e29

Browse files
authoredApr 19, 2022
Merge pull request #166 from GabrielGaspar447/master
docs: add mongoose import to typescript example
2 parents 5ea24b8 + 26f5d43 commit 2259e29

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,22 @@ Prior to version `1.5.0`, types need to be installed from [DefinitelyTyped](http
5252
To declare a `PaginateModel` in your Typescript files:
5353

5454
```ts
55+
import mongoose from 'mongoose'
5556
import paginate from 'mongoose-paginate-v2';
5657

5758
// declare your schema
58-
export const institutionSchema = new Schema({ name: String });
59+
export const institutionSchema = new mongoose.Schema({ name: String });
5960

6061
// paginate with this plugin
6162
institutionSchema.plugin(paginate);
6263

6364
// declare a mongoose document based on a Typescript interface representing your schema
64-
interface InstitutionDocument extends Document, InstitutionData {}
65+
interface InstitutionDocument extends mongoose.Document, InstitutionData {}
6566

6667
// create the paginated model
6768
const model = mongoose.model<
6869
InstitutionDocument,
69-
PaginateModel<InstitutionDocument>
70+
mongoose.PaginateModel<InstitutionDocument>
7071
>('Institutions', institutionSchema, 'institutions');
7172
```
7273

0 commit comments

Comments
 (0)
Please sign in to comment.