Master Drizzle ORM's vocabulary — schema definition, type-safe queries, migrations with drizzle-kit, and returning clauses.
0 / 5 completed
1 / 5
During a PR review, a teammate defines a table using pgTable from Drizzle ORM. A junior asks what pgTable does. The correct answer is:
pgTable('users', { id: serial('id').primaryKey(), ... }) creates a TypeScript schema object. No SQL runs at definition time — queries and migrations use this object.
2 / 5
In a standup, a developer asks how to run a Drizzle schema change on the database without writing SQL. You recommend drizzle-kit push. What does it do?
drizzle-kit push introspects the live database, diffs it against the Drizzle schema, and applies DDL changes without generating SQL migration files — useful for development iteration.
3 / 5
In a code review, a query uses Drizzle's db.select().from(users).where(eq(users.email, input)). A reviewer asks why eq() is used instead of a template literal. The reason is:
Drizzle operators (eq, and, gt, etc.) build parameterised SQL and provide TypeScript type checking on column types — preventing SQL injection and catching type errors at compile time.
4 / 5
A teammate wants to insert a row and get the inserted record back. In a PR review, you suggest using .returning(). How does .returning() work in Drizzle for Postgres?
.returning() appends RETURNING * (or specific columns) to the Postgres INSERT/UPDATE/DELETE, returning affected rows in the same query — no extra SELECT needed.
5 / 5
In a design review, the team needs to update multiple fields conditionally. You propose using Drizzle's db.update(table).set({ field: value }).where(...). A colleague asks whether Drizzle update statements are type-checked. The answer is:
Drizzle's .set() object is typed against the table schema. TypeScript reports errors if you reference non-existent columns or pass values of the wrong type — bugs caught at compile time.