What does none
do?
The none
keyword lets you filter a parent record when
no related records meet the given conditions.
It’s perfect for queries like “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>";
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 if zero related records match the condition — ideal for “doesn’t belong to” checks.