None
Filter parent records where no related records match the given condition.
What Does none Do?
The none keyword filters a parent record
when zero related records meet the conditions provided.
It is perfect for queries such as “icons with no categories named X”.
Supported Operations
- findMany
- findFirst
- findFirstOrThrow
- findUnique
- findUniqueOrThrow
- aggregate
- count
- groupBy
Example: Filtering by Related Models Using none
use Lib\Prisma\Classes\Prisma;
$prisma = Prisma::getInstance();
$icons = $prisma->icon->findMany([
'where' => [
'categories' => [
'none' => [
'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 have
no related category whose name equals $categoryName.
The none operator ensures the parent record is included only when
zero related records match—ideal for “doesn’t belong to” or exclusion checks.