Some
Filter parent records where at least one related record matches the given condition.
What Does some Do?
The some keyword lets you filter a parent record
based on whether at least one related record matches the provided conditions.
It is ideal for many-to-many or one-to-many relations where you need “at least one” logic.
Supported Operations
- findMany
- findFirst
- findFirstOrThrow
- findUnique
- findUniqueOrThrow
- aggregate
- count
- groupBy
Example: Filtering by Related Models using some
use Lib\Prisma\Classes\Prisma;
$prisma = Prisma::getInstance();
$icons = $prisma->icon->findMany([
'where' => [
'categories' => [
'some' => [
'name' => [
'equals' => $categoryName
]
]
]
],
'include' => [
'categories' => true
],
'orderBy' => [
'name' => 'asc'
]
]);
echo "<pre>";
echo "Icons found: " . print_r($icons, true);
echo "</pre>";
Explanation
This query returns all icon records that belong to at least one category whose
name equals $categoryName.
The some operator ensures the parent record is included if
any related record matches the condition—perfect for “has one or more” scenarios.