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

schema.ts — drizzle-orm Source File

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

File typescript DrizzleORM SQLDialects 5 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73["schema.ts"]
  62c695d3_7eff_3822_db70_ce6b25ccdb04["table.ts"]
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73 --> 62c695d3_7eff_3822_db70_ce6b25ccdb04
  ed204ff7_3e66_4124_7788_616d3713b13c["mysqlTableWithSchema"]
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73 --> ed204ff7_3e66_4124_7788_616d3713b13c
  f3a29a26_df86_4100_d5ea_bc3a420b1722["view.ts"]
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73 --> f3a29a26_df86_4100_d5ea_bc3a420b1722
  e0b816c4_7b35_2969_3889_1c8b49c14c60["mysqlViewWithSchema"]
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73 --> e0b816c4_7b35_2969_3889_1c8b49c14c60
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  194c3b0b_7164_9ad5_57b9_5c4bf9729c73 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  style 194c3b0b_7164_9ad5_57b9_5c4bf9729c73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { entityKind, is } from '~/entity.ts';
import { type MySqlTableFn, mysqlTableWithSchema } from './table.ts';
import { type mysqlView, mysqlViewWithSchema } from './view.ts';

export class MySqlSchema<TName extends string = string> {
	static readonly [entityKind]: string = 'MySqlSchema';

	constructor(
		public readonly schemaName: TName,
	) {}

	table: MySqlTableFn<TName> = (name, columns, extraConfig) => {
		return mysqlTableWithSchema(name, columns, extraConfig, this.schemaName);
	};

	view = ((name, columns) => {
		return mysqlViewWithSchema(name, columns, this.schemaName);
	}) as typeof mysqlView;
}

/** @deprecated - use `instanceof MySqlSchema` */
export function isMySqlSchema(obj: unknown): obj is MySqlSchema {
	return is(obj, MySqlSchema);
}

/**
 * Create a MySQL schema.
 * https://dev.mysql.com/doc/refman/8.0/en/create-database.html
 *
 * @param name mysql use schema name
 * @returns MySQL schema
 */
export function mysqlDatabase<TName extends string>(name: TName) {
	return new MySqlSchema(name);
}

/**
 * @see mysqlDatabase
 */
export const mysqlSchema = mysqlDatabase;

Domain

Subdomains

Classes

Frequently Asked Questions

What does schema.ts do?
schema.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in schema.ts?
schema.ts defines 2 function(s): isMySqlSchema, mysqlDatabase.
What does schema.ts depend on?
schema.ts imports 5 module(s): entity.ts, mysqlTableWithSchema, mysqlViewWithSchema, table.ts, view.ts.
Where is schema.ts in the architecture?
schema.ts is located at drizzle-orm/src/mysql-core/schema.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/mysql-core).

Analyze Your Own Codebase

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

Try Supermodel Free