DEV Community

Cascade Deletion: What Happens to Comments When You Delete Your Post MongoDB

Shreelaxmi Hegde on October 11, 2025

When you delete your account or post, everything linked to it(comments, likes, followers) disappears too. But have you ever wondered what really h...
Collapse
 
alexandru-ene-dev profile image
Alexandru Ene

After learning a bit of backend development (Node.js, Express.js, MongoDB), I felt kind of dizzy. Too many information about to explode and get lost.

I decided that, instead of going with small projects that won't challenge me so much, to try something bigger, related more to real life, something that I have no idea how to build.

Which I did and noticed you learn a lot more. Because you have to think about file structure, clean code and to make it work, more importantly.

Collapse
 
shreelaxmihegde profile image
Shreelaxmi Hegde

totally agree!
I’ve experienced the same.

One thing I found and have been following is ->
If you are learning a new language or framework, it’s best to start with tutorials and build mini projects to get comfortable with the basics.
Once you’re confident, move on to a fully working project that mimics real-world applications, and keep learning as you build.

When you want to add a new feature, just explore resources based on your needs. Most concepts only truly click when you understand why you need them.

I realized we should think and act like fullstack devs, not just students. Real expertise comes only by getting your hands dirty and building things.

what do you think?

Collapse
 
alexandru-ene-dev profile image
Alexandru Ene

Totally agree. It's mostly my way of learning too. Thinking you are a real dev makes you confident. It helps you keep going and make progress.

Collapse
 
xwero profile image
david duymelinck

I would have comments and likes as a part of the posts. I would only reference the the user id of the comments and likes.

Collapse
 
shreelaxmihegde profile image
Shreelaxmi Hegde

Yes,
Depending on our needs and how collections are related (like one to one, one to few, or one to many), we have to design the database and decide whether to embed documents or reference them.

Collapse
 
xwero profile image
david duymelinck

I just wanted to address the example you gave where it looks like comments and likes are in a separate collection.
I think it takes away a bit of the validity of your core argument, which it shouldn't.

Thread Thread
 
shreelaxmihegde profile image
Shreelaxmi Hegde

Yeah, you’re right.
that example did make things a bit confusing 😅
I’ve updated the blog with a clearer one that fits the context better. Thanks for pointing it out!

Collapse
 
suryakant_91 profile image
Suryakant Kumar

Nice. It helps me.

Collapse
 
shreelaxmihegde profile image
Shreelaxmi Hegde

Glad it helped! 😊