giliev giliev - 2 years ago 117
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!

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download