Is it possible to have specific embedded documents expire on a specified date?

As I could see I can only set an expire date for referenced documents not embedded ones. I have a subdocument thats embedded (an array of objects) and I would like to expire each object at a specified time. Is this anyhow possible if said documents are embedded into a collection? Thanks!

Hi @Anna_N_A

Are you referring to the TTL index?

In the case of the TTL index, it can expire (delete) documents after a certain amount of time or at a specific clock time. However it works on a per-document basis and not on parts of a document. That is, if you have e.g. an array of sub-documents with its own timestamp, it cannot reach into the document and remove array elements.

If this is what you want, I suggest you unwrap the array into separate documents, each with their separate timestamp so the TTL index can operate on them.

Otherwise if this is not what you mean, could you provide some example documents and what operation you intended?

Best regards