I have a problem using paginate in my controller after add plugin to my schema, my code is written in TypeScript 2.1, i have installed @types/mongoose-paginate in devdependencies.
[ts] severity: 'Error' message: 'Property 'paginate' does not exist on type 'Model'.'
My Controller:
export function getAllArtists(req, res) {
Artist.paginate({}, { page: 3, limit: 10 }, function(err, result) {
// ...
// ...
});
My Schema:
'use strict'
import {Document, model, Model, Schema} from 'mongoose';
import * as mongoosePaginate from 'mongoose-paginate';
interface IArtist extends Document {
name: String;
description: String;
image: String;
}
const ArtistSchema: Schema = new Schema({
name: String,
description: String,
image: String
});
ArtistSchema.plugin(mongoosePaginate);
export const ArtistModel: Model<IArtist> = model<IArtist>('Artist', ArtistSchema);
Thanks,