Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Drizzle ORM · Function

gte

gte builds a Drizzle filter for values greater than or equal to a threshold. Use it in where clauses with a literal or another column.

How it works

The gte operator creates a comparison condition where the first operand is greater than or equal to the second. Use it in a query's where clause with a column and a literal value, or compare two columns directly.

Syntax

gte(column, valueOrColumn)

Parameters

NameTypeDescription
leftSQL expressionColumn or SQL expression whose value is tested.
rightvalue or SQL expressionLiteral value or column/SQL expression compared with the first operand.

Returns

A SQL condition representing a greater-than-or-equal comparison.

Key points

  • gte keeps rows whose left-hand value is at least the right-hand value, including equality.
  • Import gte from the main drizzle-orm package alongside other filter and conditional operators.
  • Apply the operator through a query's where clause to filter selected rows.
  • The operator maps to SQL's greater-than-or-equal comparison, written as >=.
  • The second operand can be another column, enabling row-level column-to-column comparisons.

Common mistakes

  • Filter values are parameterized automatically, so do not concatenate user input into SQL to implement this comparison.

Example: Filter rows with a lower bound

import { gte } from "drizzle-orm";

const result = await db
  .select()
  .from(users)
  .where(gte(users.age, 18));

Selects users whose age is at least 18.

When to use it

Inclusive lower-bound filtering

Retrieve records meeting a minimum numeric, date, or ordered-value threshold.

Column-to-column comparison

Select rows where one field is at least as large as another field in the same row.

Compound filtering

Compose a minimum-value predicate with other Drizzle conditions in a larger query.

Interview questions

QWhat does Drizzle ORM's gte operator do?

gte means “greater than or equal to” and is imported from drizzle-orm. In a where clause, gte(table.column, 5) produces a comparison equivalent to column >= 5.

Follow-up: Can the right-hand operand be another column? Yes: pass the second column expression, such as gte(table.column1, table.column2), to compare columns directly.

QHow would you filter records using a numeric lower bound?

The first argument is the column or expression being tested, and the second is the threshold or comparison expression. For example, gte(users.age, 18) retains rows where users.age is at least 18.

Follow-up: What SQL comparison does it represent? It represents >=, so equality is included along with larger values.

QCan gte compare two columns?

Use gte in the query builder's where method after selecting from a table. The resulting condition can compare a column against either a value or another column.

Follow-up: How should dynamic values be supplied? Pass them as the second argument; Drizzle parameterizes filter-operator values automatically.

  • gt
  • eq
  • ne
  • and
  • or
  • sql

Source: Filters - Drizzle ORM. Checked 2026-10-16.