What does every do?

The every keyword lets you filter a parent record when all related records meet the given conditions. Note · If a parent has no related records, the condition is considered satisfied (i.e. the filter returns true).

Supported Operations

  • findMany
  • findFirst
  • findFirstOrThrow
  • findUnique
  • findUniqueOrThrow
  • aggregate
  • count
  • groupBy

Example: Filtering by Related Models using every


use Lib\Prisma\Classes\Prisma;

$prisma  = Prisma::getInstance();
$icons   = $prisma->icon->findMany([
    'where' => [
        'categories' => [
            'every' => [
                'name' => [
                    'equals' => $categoryName
                ]
            ]
        ]
    ],
    'include' => [
        'categories' => true
    ],
    'orderBy' => [
        'name' => 'asc'
    ]
]);

echo "<pre>";
echo "Icons found: " . print_r($icons, true);
echo "</pre>";

This query returns all icon records where every related category (if any) has a name equal to $categoryName. Use the every operator for “all related items match” scenarios.