These are chat archives for Automattic/mongoose

30th
Sep 2018
Vladimir Šterjoski
@sterjoski
Sep 30 2018 12:16
@lineus is it possible to omit some fields when .populateing?
Kev
@lineus
Sep 30 2018 12:23
@sterjoski yeah, you can use the select property to omit fields if you pass an object into populate. If you just pass in a string to populate, you can pass in a second string to select/deselect certain fields. The selections have to be all inclusive or exclusive ( with the exception of the _id field ).
Vladimir Šterjoski
@sterjoski
Sep 30 2018 13:05
got it, thanks
Vladimir Šterjoski
@sterjoski
Sep 30 2018 16:44
One last thing, can I force populate to return an array, even if it's an array with only one object in it? In your example some with virtual/populate some users return F as an array and some return just one object {}. I'd like it to consistently be an array so .map works for every user.
Vladimir Šterjoski
@sterjoski
Sep 30 2018 16:57
and .forEach.