对象没有方法'__super__'

时间:2013-05-30 13:55:09

标签: node.js mongodb mongoose

我扩展了猫鼬保存功能:

用户架构是:

var mongoose = require('mongoose');
var Schema    = mongoose.Schema,
ObjectId    = Schema.ObjectId;

var UserSchema = new mongoose.Schema({
  Name: String,
  Surname: String,
  login:   {type: String, required: true},
  Password:  {type: String, required: true},
  email: { type: String, index: { unique: true } },
  Age: Number
});

扩展方法是:

UserSchema.methods.save = function(okFn, failedFn) {
  if (this.isValid()) {
    this.__super__(okFn);
  } else {
    failedFn();
  }
};

在'保存'上尝试它会给我错误:

TypeError: Object { object fields and values } has no method '__super__'

0 个答案:

没有答案