In Mongoose, I can use the query to fill in additional fields after the query. I can also fill in several paths, for example
Person.find({}) .populate('books movie', 'title pages director') .exec()
However, this will create a search in the book collecting fields for the title, pages and director, as well as a search in the film collecting fields for the title, pages and director. I want to get the title and pages only from books, and the director from the film. I could do something like this:
Person.find({}) .populate('books', 'title pages') .populate('movie', 'director') .exec()
which gives me the expected result and queries.
But is there a way to have the behavior of the second fragment using the same "one line" syntax, such as the first fragment? The reason for this is because I want to programmatically determine the arguments for the fill function and pass it. I cannot do this for multiple fill calls.
javascript mongoose
Se7enDays Jan 12 '14 at 12:37 a.m. 2014-01-12 00:37
source share