是否可以将方法添加到mongoose模式的属性?
所以你可以像这样访问它
user.properties[2].toString()
模式
var User = new mongoose.Schema({
username: String,
properties: [{
name: String,
other: String,
...
}],
...
});
是否可以为其所有" properties
"添加方法?
User.properties.methods.toString = function() {
return (this.name + this.other);
// `this` would be [property]
}