How do i prevent recursion in my MongoDB database?

Viewed 55

I am making a simple social media platform and i am using MongoDB with Morphia and Spring boot. In my database a user has a list of users that they follow, however if that list contains a user that also follows them, it creates an infite going back and foward of loading the data of each user. How can i prevent such an issue? i have tried enableing lazy loading with @Reference(lazy=true) but that does not help.

0 Answers
Related