Home / Function/ is() — drizzle-orm Function Reference

is() — drizzle-orm Function Reference

Architecture documentation for the is() function in entity.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  c020d230_75a2_3639_d9a6_35f2ba7fd5bc["is()"]
  bc6d807f_7198_da43_c1e6_911af80c80ee["entity.ts"]
  c020d230_75a2_3639_d9a6_35f2ba7fd5bc -->|defined in| bc6d807f_7198_da43_c1e6_911af80c80ee
  8e92df7f_f898_3f9a_f9be_9a9823f94a4f["get()"]
  8e92df7f_f898_3f9a_f9be_9a9823f94a4f -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  fd2db1bb_b6da_94bf_ea4b_4502ee7a2b9d["mapColumnsInSQLToAlias()"]
  fd2db1bb_b6da_94bf_ea4b_4502ee7a2b9d -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  910b7f81_1088_02ad_1eb1_cd8ed92bd0b4["extractTablesRelationalConfig()"]
  910b7f81_1088_02ad_1eb1_cd8ed92bd0b4 -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  95b7f368_fe07_2aac_c3ae_6c1fc186391c["normalizeRelation()"]
  95b7f368_fe07_2aac_c3ae_6c1fc186391c -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  df653029_504d_b816_43f6_f1fa1183d155["mapRelationalRow()"]
  df653029_504d_b816_43f6_f1fa1183d155 -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  a40f58bf_d603_3d63_ca91_0e1365452bad["get()"]
  a40f58bf_d603_3d63_ca91_0e1365452bad -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  7d57d70d_cd39_acc3_0c7e_58fea2a074cd["mapResultRow()"]
  7d57d70d_cd39_acc3_0c7e_58fea2a074cd -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  992adf9d_d07d_06b0_049c_a9a79e923c80["orderSelectedFields()"]
  992adf9d_d07d_06b0_049c_a9a79e923c80 -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  8f976d74_38e7_6a63_ed00_d2b87643ee94["mapUpdateSet()"]
  8f976d74_38e7_6a63_ed00_d2b87643ee94 -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  1afcd0f4_fc84_01bf_ac3e_adc1f2d4b7d9["getTableLikeName()"]
  1afcd0f4_fc84_01bf_ac3e_adc1f2d4b7d9 -->|calls| c020d230_75a2_3639_d9a6_35f2ba7fd5bc
  style c020d230_75a2_3639_d9a6_35f2ba7fd5bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/entity.ts lines 12–42

export function is<T extends DrizzleEntityClass<any>>(value: any, type: T): value is InstanceType<T> {
	if (!value || typeof value !== 'object') {
		return false;
	}

	if (value instanceof type) { // eslint-disable-line no-instanceof/no-instanceof
		return true;
	}

	if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
		throw new Error(
			`Class "${
				type.name ?? '<unknown>'
			}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`,
		);
	}

	let cls = Object.getPrototypeOf(value).constructor;
	if (cls) {
		// Traverse the prototype chain to find the entityKind
		while (cls) {
			if (entityKind in cls && cls[entityKind] === type[entityKind]) {
				return true;
			}

			cls = Object.getPrototypeOf(cls);
		}
	}

	return false;
}

Domain

Subdomains

Frequently Asked Questions

What does is() do?
is() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/entity.ts.
Where is is() defined?
is() is defined in drizzle-orm/src/entity.ts at line 12.
What calls is()?
is() is called by 10 function(s): extractTablesRelationalConfig, get, get, getTableLikeName, mapColumnsInSQLToAlias, mapRelationalRow, mapResultRow, mapUpdateSet, and 2 more.

Analyze Your Own Codebase

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

Try Supermodel Free