Reference

Query options

The full argument surface for reads, projections, ordering, pagination, filter operators, and metadata.

This page is the reference for the arguments accepted by reads and (where noted) writes.

Read arguments

Accepted by findMany, findFirst, findOne, and findUnique:

Prop

Type

count and exists accept only where, cursor, and meta.

findUnique is the strictest of the read helpers semantically, but it still accepts the same query-argument shape as the other reads. The main difference is intent: use it when the where clause targets a unique lookup.

Filter operators

Operators available inside where, by column type. A bare value means equals; null matches nullable columns.

Column typeOperators
Stringequals, in, notIn, contains, startsWith, endsWith, mode, not
Number / bigint / Dateequals, in, notIn, lt, lte, gt, gte, not
Booleanequals, not
LogicalAND, OR, NOT
To-one relationis, isNot
To-many relationsome, every, none

mode is 'default' or 'insensitive' (case-insensitive string matching). See filters and relations for examples.

Projections

// select — narrows, scalars + relations
{ select: { id: true, author: { select: { name: true } } } }

// include — keeps all scalars, adds relations
{ include: { author: true } }

A relation value can be true or a nested read-args object (with its own where, select, orderBy, take). See selecting fields.

Pagination arguments

paginate accepts everything above plus:

Prop

Type

It returns { data, pagination: { count, hasNext, hasPrevious } }. See pagination.

Write-specific arguments

Read args are only part of the API surface. The write methods add a few important options that deserve their own reference.

Single-row writes

MethodExtra args
createdata, skipDuplicates?, select?, include?, meta?
updatewhere, data, select?, include?, meta?
deletewhere, select?, include?, meta?
upsertwhere, create, update, select?, include?, meta?

Batch writes

MethodExtra args
createManydata[], skipDuplicates?, select?, include?, meta?
updateManywhere?, data, meta?
deleteManywhere?, meta?
upsertManydata[], target, update, select?, batchSize?, where?, meta?

upsertMany details

import { sql } from 'drizzle-orm';

await client.users.upsertMany({
	data: [
		{ email: 'a@example.com', name: 'A', active: true },
		{ email: 'b@example.com', name: 'B', active: false },
	],
	target: ['email'],
	update: (ctx) => ({
		name: ctx.excluded.name,
		active: ctx.excluded.active,
		updatedAt: sql`now()`,
	}),
	batchSize: 1000,
	where: sql`users.disabled = false`,
});

update accepts four shapes:

  • 'all'
  • an explicit column list
  • an explicit update object
  • a function receiving { excluded, sql, table }

where must be a Drizzle SQL fragment. It is not the same as the normal structured where filter used by reads and single-row writes.

On this page