VibORM
Filtering

Filtering

Filter operators for different field types

Filtering

The where clause supports various filter operators depending on the field type.

Basic Filtering

const users = await client.user.findMany({
  where: {
    role: "ADMIN",              // Exact match
    active: true,               // Boolean
    age: { gte: 18 },           // Comparison
    name: { contains: "alice" }, // String search
  },
});

Common Operators

All field types support:

OperatorDescription
equalsExact match
notNegation
inMatch any in array
notInMatch none in array
where: {
  role: "ADMIN",                    // Shorthand for equals
  role: { equals: "ADMIN" },        // Explicit equals
  role: { not: "GUEST" },           // Not equal
  role: { in: ["ADMIN", "MODERATOR"] },  // In array
  role: { notIn: ["GUEST", "BANNED"] },  // Not in array
}

Logical Operators

Combine conditions with AND, OR, NOT:

// AND (implicit)
where: {
  role: "ADMIN",
  active: true,
}

// AND (explicit)
where: {
  AND: [
    { role: "ADMIN" },
    { active: true },
  ],
}

// OR
where: {
  OR: [
    { role: "ADMIN" },
    { email: { endsWith: "@company.com" } },
  ],
}

// NOT
where: {
  NOT: { role: "GUEST" },
}

// Combined
where: {
  AND: [
    { active: true },
    {
      OR: [
        { role: "ADMIN" },
        { email: { endsWith: "@company.com" } },
      ],
    },
  ],
}

Filter by Type

On this page