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. 10 imports, 0 dependents.

File typescript DrizzleORM DatabaseDrivers 10 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39["update.ts"]
  554a7c60_d7ae_c68e_f0c9_e3a02afcefb7["db.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 554a7c60_d7ae_c68e_f0c9_e3a02afcefb7
  998b0a13_62af_9408_d100_2bb61b49b6b9["tables.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 998b0a13_62af_9408_d100_2bb61b49b6b9
  d5069778_165e_a727_2a3f_ca5ade9bb1ab["cities"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> d5069778_165e_a727_2a3f_ca5ade9bb1ab
  4d7e77e2_6504_f5a5_4a03_156acfe671d4["users"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 4d7e77e2_6504_f5a5_4a03_156acfe671d4
  0d277acf_0d68_9daf_8724_642232a89719["pg"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 0d277acf_0d68_9daf_8724_642232a89719
  25b05299_f48f_bceb_01ca_1343d330a8f7["utils.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 25b05299_f48f_bceb_01ca_1343d330a8f7
  fa14e9c0_b73d_4bcb_463b_adf18df8a285["index.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> fa14e9c0_b73d_4bcb_463b_adf18df8a285
  5c46beaf_8b59_d2e3_def3_8af6daf1fccd["index.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> 5c46beaf_8b59_d2e3_def3_8af6daf1fccd
  be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  60a03814_2a9b_3c6b_eb8c_0bf124b68d39 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  style 60a03814_2a9b_3c6b_eb8c_0bf124b68d39 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { QueryResult } from 'pg';
import type { Equal } from 'type-tests/utils.ts';
import { Expect } from 'type-tests/utils.ts';
import type { PgUpdate } from '~/pg-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<QueryResult<never>, 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<QueryResult<never>, 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 PgUpdate>(qb: T) {
		return qb.where(sql``).returning();
	}

	const qbBase = db.update(users).set({}).$dynamic();
	const qb = dynamic(qbBase);
	const result = await qb;
// ... (219 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, DatabaseDrivers 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 10 module(s): cities, db.ts, index.ts, index.ts, pg, sql.ts, tables.ts, users, and 2 more.
Where is update.ts in the architecture?
update.ts is located at drizzle-orm/type-tests/pg/update.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/type-tests/pg).

Analyze Your Own Codebase

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

Try Supermodel Free