Home / File/ update.ts — drizzle-orm Source File

update.ts — drizzle-orm Source File

Architecture documentation for update.ts, a typescript file in the drizzle-orm codebase. 9 imports, 0 dependents.

File typescript DrizzleORM QueryBuilders 9 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3["update.ts"]
  02ee7a70_490f_3b80_fa60_d59aaa62cd1d["db.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> 02ee7a70_490f_3b80_fa60_d59aaa62cd1d
  caa15051_4c2c_cd8b_fcc3_001b783b7336["tables.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> caa15051_4c2c_cd8b_fcc3_001b783b7336
  d929dcac_4d3c_8543_2323_07023b291633["cities"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> d929dcac_4d3c_8543_2323_07023b291633
  af8d5a1e_788a_d02e_b32c_8fb7cd129ff9["users"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> af8d5a1e_788a_d02e_b32c_8fb7cd129ff9
  25b05299_f48f_bceb_01ca_1343d330a8f7["utils.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> 25b05299_f48f_bceb_01ca_1343d330a8f7
  076448f5_e30d_7700_bbe9_f5d1e76b579a["index.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> 076448f5_e30d_7700_bbe9_f5d1e76b579a
  5c46beaf_8b59_d2e3_def3_8af6daf1fccd["index.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> 5c46beaf_8b59_d2e3_def3_8af6daf1fccd
  be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  style 6d1c06eb_5f62_2e43_a87d_f1da58bf01b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Equal } from 'type-tests/utils.ts';
import { Expect } from 'type-tests/utils.ts';
import type { GelUpdate } from '~/gel-core/index.ts';
import { eq } from '~/sql/expressions/index.ts';
import { sql } from '~/sql/sql.ts';
import type { Simplify } from '~/utils.ts';
import { db } from './db.ts';
import { cities, salEmp, users } from './tables.ts';

const update = await db.update(users)
	.set({
		text: 'John',
		age1: 30,
	})
	.where(eq(users.id, 1));
Expect<Equal<unknown, typeof update>>;

const updateStmt = db.update(users)
	.set({
		text: 'John',
		age1: 30,
	})
	.where(eq(users.id, 1))
	.prepare('updateStmt');
const updatePrepared = await updateStmt.execute();
Expect<Equal<unknown, typeof updatePrepared>>;

const updateReturning = await db.update(users)
	.set({
		text: 'John',
		age1: 30,
	})
	.where(eq(users.id, 1))
	.returning({
		text: users.text,
	});
Expect<Equal<{ text: string | null }[], typeof updateReturning>>;

const updateReturningStmt = db.update(users)
	.set({
		text: 'John',
		age1: 30,
	})
	.where(eq(users.id, 1))
	.returning({
		text: users.text,
	})
	.prepare('updateReturningStmt');
const updateReturningPrepared = await updateReturningStmt.execute();
Expect<Equal<{ text: string | null }[], typeof updateReturningPrepared>>;

{
	function dynamic<T extends GelUpdate>(qb: T) {
		return qb.where(sql``).returning();
	}

	const qbBase = db.update(users).set({}).$dynamic();
	const qb = dynamic(qbBase);
	const result = await qb;
	Expect<Equal<typeof users.$inferSelect[], typeof result>>;
// ... (218 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does update.ts do?
update.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, QueryBuilders subdomain.
What functions are defined in update.ts?
update.ts defines 2 function(s): dynamic, withReturning.
What does update.ts depend on?
update.ts imports 9 module(s): cities, db.ts, index.ts, index.ts, sql.ts, tables.ts, users, utils.ts, and 1 more.
Where is update.ts in the architecture?
update.ts is located at drizzle-orm/type-tests/geldb/update.ts (domain: DrizzleORM, subdomain: QueryBuilders, directory: drizzle-orm/type-tests/geldb).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free