Problem filtering an array, cond if field is null does not work

I am facing some problems when trying to filter an array in a pipeline aggregation;
Basically I need to keep the items that “deletion” attribute is null, but it’s ignoring my filter condition, and retrieve-me an empty array;

This is the source array

[
    {
        "id": "0213f0b7-57d4-43fc-b44d-220257a0689f",
        "schemaId": "b6b54f78-759b-4e1c-92b4-5b8c1e4c17d2",
        "organizationId": "5b1860dd-cace-478a-81c3-22c13808d17a",
        "establishmentId": "c2b4b151-830b-4469-ab39-18125809436a",
        "userId": "725f91d4-ecc8-40c3-bb53-a1e9bb05a654",
        "payload": {
            "equipamento": "2398bb90-0930-4f34-81ae-47eb913f6bbf",
            "anoMes": "2024-09",
            "quantidade": 1
        },
        "creation": "2024-09-24T20:36:12.509Z",
        "updation": null,
        "deletion": "2024-09-24T20:37:13.509Z",
        "history": []
    },
    {
        "id": "751b32c9-d0d3-40ba-b97d-94b0cee58d84",
        "schemaId": "b6b54f78-759b-4e1c-92b4-5b8c1e4c17d2",
        "organizationId": "5b1860dd-cace-478a-81c3-22c13808d17a",
        "establishmentId": "c2b4b151-830b-4469-ab39-18125809436a",
        "userId": "725f91d4-ecc8-40c3-bb53-a1e9bb05a654",
        "payload": {
            "equipamento": "2398bb90-0930-4f34-81ae-47eb913f6bbf",
            "anoMes": "2024-08",
            "quantidade": 1
        },
        "creation": "2024-09-24T20:36:46.453Z",
        "updation": null,
        "deletion": null,
        "history": []
    }
]

My filter:

$addFields: {
    "falha": {
        $filter: {
            input: "$falhaFull",
            as: "falha",
            cond: {
                $eq: [ "$$falha.deletion", null ]
            }
        }
    }
}

I need to skip the first item, because deletion key has a value;
but it does return an empty array :frowning:

Please share the whole document. It could simply be because the field is not named falhaFull. Typos occur all the time.

Try testing with $type for the value string value missing.

You should not be storing your date as string. The date data type is faster, smaller and provides a richer API.

@Davi_Arimateia, have you tried my proposition that I posted 7 days ago:

If that worked for you please mark my post as the solution.

If it did not work please share the exact $filter your tried and we can help fine tune.

Thanks