VibORM
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:

OperatorDescription
isMatch related record
isNotExclude matching related record

To-Many Relations

For oneToMany and manyToMany relations:

OperatorDescription
someAt least one match
everyAll must match
noneNo 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 },
    },
  },
});

Pages

On this page