Skip to content

Commit 26f5d43

Browse files
authoredApr 19, 2022
docs: add mongoose import to typescript example
When I first used the library I had no idea where "PaginateModel" was coming from and had to look in an issue from the library to find out. This change will make it clear that it's coming from mongoose.
1 parent 5ea24b8 commit 26f5d43

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.