2

我写了一个插件:

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

如果我在插件之外编写静态方法,它就可以工作。这是来自猫鼬的限制吗?

4

0 回答 0