在将插件添加到我的模式后,我在控制器中使用分页时遇到问题,我的代码是用 TypeScript 2.1 编写的,我已经在 devdependencies 中安装了 @types/mongoose-paginate。
[ts] 严重性:'错误'消息:'类型'模型'上不存在属性'分页'。'
我的控制器:
export function getAllArtists(req, res) {
Artist.paginate({}, { page: 3, limit: 10 }, function(err, result) {
// ...
// ...
});
我的架构:
'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);
谢谢,