Mongoose - multiple relations between objects Mongoose - multiple relations between objects mongoose mongoose

Mongoose - multiple relations between objects


No you do not need two way links.

All you need are

Blog->CategoryBlog->EditorsBlog->OwnersPost->Blog

Because your categories and users never change object ids, then you don't have to worry about updating references inside of blogs. In addition, when you want to remove a blog, don't delete the records. Instead, add a flag that marks the blog as deleted. When you display content, just check the delete flag of the corresponding blog, or even add a condition to your query to avoid those results entirely. (This also has the benefit of preserving history)

To summarize, instead of creating two way links, you can just link from the more specific and changeable content to the more static content. To delete records, you either add a delete flag and don't worry about chasing records, or you can select all posts that have the blog_id in question and remove them first.