0

I want to create two Collections, First "Users", second "Video" in my mongodb. Each record in "Users" collection will have a "Video" record associated with it. I want to link these two Collections in such a way that if i delete a Users record, the associated "Video" record should be deleted with it.

I know that this can be achieved with JPA by using annotations like @one-to-one(etc), however how can i achieve this using mongodb?

I am new to mongodb and spring boot, if there is any way to implement this please let me know. I have seen below posts but it did not help me come to a conclusion... hence i am posting here.

Spring Data MongoDB: how to implement "entity relationships"?

https://spring.io/blog/2021/11/29/spring-data-mongodb-relation-modelling

TL;DR = what i want to achieve: Delete (n) from Video collection if (n) from Users collection is deleted or how to achieve one-to-one mapping of two collections in mongoDb?

user448477
  • 65
  • 1
  • 8

0 Answers0