调用静态方法到Mongoose中的插件中的模式
我写了一个插件做:
module.exports = function (schema, options) { schema.statics.customFunction = function (criteria) { // Code }; };
这是我的模式:
var customPlugin = require('./plugin'); var customSchema = new mongoose.Schema({ // Schema }); customSchema.plugin(customPlugin, {}); var model = mongoose.model('Custom', customSchema); model.customFunction() // I have a undefined here
如果我在插件之外编写我的静态方法,它正在工作。 这是来自mongoose的限制吗?
- 在尝试使用meteor.js连接到mongoDB时出现TypeError错误
- 使用node.js / MongoDB / Mongoose进行callback
- MongoDB:mongos进程,node-mongodb-native,connect-session-mongo
- Mongoose,在模式(枚举)中定义OR引用?
- 用另一个sorting字段进行范围查询的mongodb分页
- MongoDB返回undefined
- Node.js / Mongoose:发送信息到一个函数,并识别信息来操作
- 如何避免在mongoose中重复的条目
- 承诺呼叫和Express中间件中的Mongoose句柄validation错误