I am working on two different projects right now and I encountered the same dilemma in both. I have some documents that probably should be embedded in another document, but in both cases that is causing me a headache.
Project 1 - some sort of discussion forum. I have posts and comments on those posts. I thought it would make sense to embed the comments in the post document, but I ran into problems when I tried getting a list of all the comments made by a user. It probably wouldn’t be a very frequent request (not as frequent as getting all the comments for a post), but it seemed nearly impossible. I ended up de-embedding the posts and doing a .populate(‘comments’) when loading a post. It works, but I am worried that it might eventually become too slow.
Project 2 - The voting app. I embedded the options inside the survey. I really don’t see a case where I would need the options outside of the context of the survey. So embedding would make sense, right? Now I am trying to make a post request to update an option when someone votes. Getting to the embedded option seems overly complicated. Even a request to find the option will return the survey, and then I need to loop through that survey’s options array to get the option. Is that right? Or is there a better way to do this?
Is embedding ever a good idea??