主题。我想在它的静态方法中初始化一个新的模型实例:
var Schema = new mongoose.Schema({...});
//...
Schema.statics.createInstance = function (name, pass) {
var newPerson = new Person; // <--- or 'this', or 'Schema'?
newPerson.name = name;
newPerson.pass = pass;
newPerson.save();
return newPerson;
}
// ...
module.exports = db.model("Person", Schema);
我怎么能做到这一点?