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

Drizzle ORM · Type Alias

InferSelectModel

InferSelectModel derives a TypeScript select-row model from a Drizzle table schema. Pass the table type with typeof to avoid manually duplicating the row shape.

How it works

InferSelectModel derives the TypeScript shape of rows selected from a Drizzle table schema. Pass the table type as its generic argument; the resulting alias can describe values returned by select queries without manually duplicating the schema.

Syntax

InferSelectModel<typeof table>

Parameters

NameTypeDescription
TTabletypeof users (a table type)A Drizzle table type whose selected-row shape should be inferred.

Returns

A TypeScript model type representing selected rows for the supplied Drizzle table.

Key points

  • The helper is part of Drizzle’s type API for deriving select models from a table schema.
  • Apply the table type with typeof, for example InferSelectModel<typeof users>.
  • Import InferSelectModel as a type from the main drizzle-orm package.
  • The table’s $inferSelect property provides an alternative syntax for the same selected-row inference.

Common mistakes

  • Do not use the deprecated InferModel helper when distinguishing selected-row and insert models; use InferSelectModel for selected rows.

Example: Infer a selected-row model

import { integer, text, sqliteTable } from "drizzle-orm/sqlite-core";
import { type InferSelectModel } from "drizzle-orm";

const users = sqliteTable("users", {
  id: integer().primaryKey({ autoIncrement: true }),
  name: text().notNull(),
});

type User = InferSelectModel<typeof users>;

const user: User = { id: 1, name: "Ada" };

Infer a TypeScript type representing rows selected from the declared table.

When to use it

Typed selected rows

Define a reusable TypeScript type for rows returned from a table.

Shared data contracts

Expose database row types from a repository or service layer without repeating column definitions.

Clear model intent

Choose explicitly between selected-row and insert-value models in application types.

Interview questions

QWhat does InferSelectModel do?

InferSelectModel is a Drizzle type helper that derives a select-row TypeScript model from a table schema. Use it as InferSelectModel<typeof users> after importing it from drizzle-orm.

Follow-up: How can the same model be inferred without the helper? Use the table’s $inferSelect property, such as typeof users.$inferSelect.

QWhat type argument does InferSelectModel require?

Its generic argument is the table type, commonly written as typeof users. The inferred result follows the columns and constraints declared in that table schema.

Follow-up: What helper represents values intended for insertion? InferInsertModel<typeof users> derives the insert model instead.

QHow does InferSelectModel relate to $inferSelect?

It is an alternative to the table property form: InferSelectModel<typeof users> is shown alongside typeof users.$inferSelect. Both are documented ways to infer a selected-row model.

Follow-up: Why prefer the explicit helper in some codebases? It makes the selected-versus-insert distinction visible at the type name, unlike the older generic InferModel.

  • InferInsertModel
  • $inferSelect
  • $inferInsert
  • InferModel

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