If I have a a Schema in Mongoose that's defined like:
var subSchema = new Schema({
some: String
});
var topSchema = new Schema({
subs: [subSchema]
});
var topModel = mongoose.model("Top", topSchema);
Is it possible to define an instance method for the sub document? I've tried the following(added before the model declaration), but it doesn't work:
subSchema.methods.someFn = function() {
return 'blah';
};