我正在使用 mongoose-auto-increment 插件,并且正在使用 TypeScript Node.js,并且我已经安装了所需的类型化定义,但是当我尝试获取自动增量的下一个计数时,我得到了这个
Property 'nextCount' does not exist on type 'Model<Document>'
我的架构是示例中的架构:
let bookSchema = new Schema({
author: { type: Number, ref: 'Author' },
title: String,
genre: String,
publishDate: Date
});
bookSchema.plugin(autoIncrement.plugin, 'Book');
var Book = connection.model('Book', bookSchema);
//// error here
Book.nextCount(function(err, count) {
});
我的 tsconfig.json 是这样的
{
"compilerOptions": {
"types" : ["node", "socket.io"],
"module": "commonjs",
"experimentalDecorators": true,
"target": "es2015",
"lib": ["es2015", "es2017", "dom"]
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
]
}