For example, in mongoose, how to realize the following Functions?
Running such logic on the database side is not recommended. Moreover, this is no different from defining such a function on NodeJS side. why must it be placed in MongoDB?
Describing the specific usage scenario may help us analyze the problem.