Let's say I have a collection containing a field that references documents from another collection, for example:
ClassEnrollment
_id | student | class ---------------------
and the classes in the class collection have the following scheme:
_id | className | teacher | building | time | days | classNumber | description ------------------------------------------------------------------------------
If I have a set of 3000 classes that I want to populate on the server, I could do something like ClassEnrollment.populate(listOfClassEnrollments, {path: 'class'});
In my situation, I do not want most class fields, but only a name. If I get a list of 3000 classes from db with all fields, I get a performance hit in the form of network delays (these 3000 classes should be transferred from the hosted db to the server, which can be 50 MB raw data if the descriptions are long)
Is there a way to populate the class bookmarks list with just a name to fill in (behind the scenes, I think it will work as a projection, so db just answers with the class name and _id instead of all the class information)?
source share