giliev giliev - 2 months ago 5x
Python Question

Expire index in mongoDB based on condition

I have

field named
model in Python. I want the document to be removed after 1 hour only if
. If I needed to remove the document after 1 hour unconditionally I would just set expire index. Is there some smart and easy way to add some conditional check to expire index?

Thank you in advance!


I am afraid it is not directly possible to add some custom logic to the periodic cleaning of expired documents but as described in the docs you could use a expire index and only set the indexed field from your application if pending = True - as documents without the field of the expire index are not removed this should work although not exactly what you requested.