Filter result with entries that doesn't contain the ID in an array

System Information
  • Strapi Version: 3.6.8
  • Operating System: MacOS
  • Database: MariaDB 10.5.11
  • Node Version: 14.15.5
  • NPM Version: 6.14.11
  • Yarn Version: none

I have a collection type (called Business Types) that the result is like this:

[
    {
    "id": 3,
    "name": "Rent",
    "notAvailableOnPropertyTypes": [
        {
            "id": 5,
            "name": "House",
        },
        {
            "id": 6,
            "name": "Apartment",
        },
    ]
    }
]

The notAvailableOnPropertyTypes is a relation of type “Business Type has many Property Types”.

I’m trying to find all the records that doesn’t have House (id = 5) in the array.

I have tried:

  • business-types?_where[notAvailableOnPropertyTypes_nin]=5
  • business-types?_where[notAvailableOnPropertyTypes.id_nin]=5
  • business-types?notAvailableOnPropertyTypes_nin=5
  • business-types?notAvailableOnPropertyTypes.id_nin=5

The expected result should be:

[
    {
    "id": 2,
    "name": "Sell", // <= is a different record =)
    "notAvailableOnPropertyTypes": [] // <- Note that this is empty =)
    }
]

Property Types:

  1. House
  2. Apartment

Business Types:

  1. Rent
  2. Sell

How can i say: Give me all the business types that a House can have?

I have created the notAvailableOnPropertyTypes to help me with this, but I cannot figure out the correct filter using the API.

Hi @rrgt19 facing the same issue. As I have dynamic zone which is again the array property in a way. Help me out on this if you have any findings on the above issue.

Using 4.0.2

Thanks in advance.