Trying to filter on a subarray where both are tru...
# orm-help
c
Trying to filter on a subarray where both are true.
Copy code
License: {
              some: {
                AND: [
                  {
                    LicenseTypeID: 2
                  },
                  {
                    LicenseTypeID: 3
                  }
                ]  
              }
There are records that meet the criteria, but this returns nothing. Any suggestions how to get the "some" to work with the AND?
1
r
@Chip Clark 👋 Put the
some
inside
AND
:
Copy code
AND: [
  { some: { LicenseTypeID: 2 } },
  { some: { LicenseTypeID: 3 } },
]
c
Ah, OK - Thanks!
I get the following error: Unknown arg
AND
in where.AND.3.License.AND for type LicenseListRelationFilter. Available args: type LicenseListRelationFilter { every?: LicenseWhereInput some?: LicenseWhereInput none?: LicenseWhereInput }
I sorted the problem. My code includes MORE than just AND of the License array.
Copy code
whereClause = {                   //   BEGINNING OF WHERE 
        OR: [
          {
            EmploymentStatus: "A"
          },
          {
            EmploymentStatus: "L"
          },
          {
            EmploymentStatus: "C"
          },
        ],                                      //  WHERE EmploymentStatus = "A", "L", or "C"
        AND: [                                  //  AND include 
          {
            OfficeLocation: {
              OfficeLocationCode: office
            }
          },
          {
            HRDepartmentID: hrdept
          },
          {
            LegalDepartmentID: legaldept
          },
          {
            License: {
              some: { LicenseTypeID: 2 }
            }
          },
          {
            License: {
              some: { LicenseTypeID: 3 }
            }
          },
          {
            ...(searchString
              ? {
                  OR: [
                    {
                      LastName: { contains: searchString },
                    },
                    {
                      FirstName: { contains: searchString },
                    },
                    {
                      MiddleName: { contains: searchString },
                    },
                    {
                      PreferredFirstName: { contains: searchString },
                    },
                    {
                      DisplayName: { contains: searchString },
                    },
                  ],
                }
              : {}),
          }
        ]
      };
Therefore I had to include a some for each LicenseTypeID
💯 1