I have a collection with status field (Pending,Completed,Failed) & createdAt field.
I want to delete records that were created more than a month and status is not equal to “Completed”
Is there a way to do that?
It seem partialFilterExpression doesn’t support that
Partial filter expression is about indexes, when you want to index only a subset of your collection. You are asking about deleting records, that would be based on a query like {createdAt:{$lt:<some-date>}, status:{$ne:"Completed"}}
Are you maybe thinking about creating a partial TTL index to automatically do these deletions? You could create a partial index but it doesn’t support dynamic date expressions (more than a month) and you’re correct that it won’t allow negation in the partialFilterExpression. In the subject you mention $in - is that because for you status:{$in:["Pending", "Failed"]} is equivalent to {$ne:"Completed"}?