Document entries gets deleted after a couple of minutes. (MongoDB Atlas)

Hi Guys,

Hoping someone can help. I am currently working on an ecommerce website(Almost done Finally!!!). After a user creates an order, the order is entered to the mongodb atlas database and everything works fine. The main issue I am having is that the recorded document is automatically deleted from the database after a couple of minutes which is a problem as users are not able to view their previous orders in their profile page. I have other collections like User, Products e.t.c. and they are all okay. The tech stack is NextJs with mongoose and mongodb installed as dependencies.

Found a solution to the issue. For anyone facing a similar issue, check the indexes tab under the collection and make sure that TTIL indexes is not enabled. TTL indexes are special single-field indexes that MongoDB can use to automatically remove documents from a collection after a certain amount of time or at a specific clock time. Please find a link below.

5 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.