Relations
Relation Queries
Query and filter data across related models
Overview
VibORM supports filtering on relations with operators that depend on the relation cardinality.
To-One Relations
For oneToOne and manyToOne relations:
| Operator | Description |
|---|---|
is | Match related record |
isNot | Exclude matching related record |
To-Many Relations
For oneToMany and manyToMany relations:
| Operator | Description |
|---|---|
some | At least one match |
every | All must match |
none | No matches |
Quick Examples
// Users with admin profile
await client.user.findMany({
where: {
profile: {
is: { role: "ADMIN" },
},
},
});
// Users with at least one published post
await client.user.findMany({
where: {
posts: {
some: { published: true },
},
},
});
// Posts with all approved comments
await client.post.findMany({
where: {
comments: {
every: { approved: true },
},
},
});