DEV Community

Discussion on: Help me decide: Embed subdocument or have a new document collection?

Collapse
 
imthedeveloper profile image
ImTheDeveloper

Thanks for the input. Filtering and managing an array is pretty simple though and is nothing beyond map reduce functions. I'll give a few options a try and see which works nice

Collapse
 
dmfay profile image
Dian Fay • Edited

It is simple! The problem is it takes time. Filtering one rep array is O(n); filtering and aggregating (for example, if you wanted to see all rep you've given) is O(n2 ). Performance may be acceptable at first but you've chosen a structure which can grow indefinitely and does not admit any shortcuts.