Answering my own question.
What I originally wanted to do was create a function that can be used in a collection of subdomains, for example:
topdoc.subs.someFn();
However, what I really did with the code in the original question was to create a function for the subdoc itself, for example:
topdoc.subs[i].someFn();
It works.
As far as I can tell, creating a function to collect pallets is not supported by Mongoose.
I got around this by defining a method in topSchema that will do what I want.
source share