Types

@system-inc/base-foundation · 515c140 · 49 symbols

DrizzleFullSchema: Record<string, T>

View source ↗

DrizzleSchema: ExtractTablesWithRelations<DrizzleFullSchema<T>>

View source ↗

Structural shape of a Drizzle table used by adapter internals. Drizzle's dialect-specific table types (SQLiteTable, MySqlTable, PgTable) are heavily inferred from schema definitions — accepting one of them as a parameter forces the caller through that inference. This shape captures just the dynamic-column-lookup behavior the shared helpers actually need.

DrizzleTableLike: Record<string, Column | undefined>

View source ↗

Helper type to extract the value type from a filter

ExtractFilterValue: F extends OrmEqualsFilter<infer T> ? T : F extends OrmNotEqualsFilter<infer T> ? T : F extends OrmGtFilter<infer T> ? T : F extends OrmGteFilter<infer T> ? T : F extends OrmLtFilter<infer T> ? T : F extends OrmLteFilter<infer T> ? T : F extends OrmInArrayFilter<infer T> ? T[] : F extends OrmNotInArrayFilter<infer T> ? T[] : F extends OrmBetweenFilter<infer T> ? [T, T] : F extends OrmNotBetweenFilter<...> ? [..., ...] : ... extends ... ? ... : ...

View source ↗

MySqlDb: MySqlDatabase<any, any, DrizzleFullSchema<AnyMySqlTable>, DrizzleSchema<AnyMySqlTable>>

View source ↗

MySqlTx: MySqlTransaction<any, any, DrizzleFullSchema<AnyMySqlTable>, DrizzleSchema<AnyMySqlTable>>

View source ↗

OrmAdapterType: "drizzle"

View source ↗

A single write operation that can be included in a writeBatch. The batch as a whole is atomic — either all operations commit or none do.

The upsert kind uses ON CONFLICT/ON DUPLICATE KEY semantics so the conflict target comes from the entity's primary key columns, not from arbitrary where conditions. Use OrmAdapter.upsert() outside a batch if you need the read-then-write variant with complex conditions.

The execute kind runs a raw write statement (built with the drizzle sql template) inside the same atomic batch — the escape hatch for bulk updates the entity API can't express (computed SET clauses, conditional shifts, increments over arbitrary conditions). No entity lifecycle hooks run for it.

OrmBatchOperation: { kind: "insert"; metadata: OrmTableMetadata; values: ReadonlyArray<OrmPartialEntity<EntityType>> } | { conditions: OrmFindOptionsWhere<EntityType>; kind: "update"; metadata: OrmTableMetadata; values: OrmPartialEntity<EntityType> } | { conditions: OrmFindOptionsWhere<EntityType>; kind: "delete"; metadata: OrmTableMetadata } | { conditions: OrmPartialEntity<EntityType>; kind: "upsert"; metadata: OrmTableMetadata; values: OrmPartialEntity<EntityType> } | { kind: "execute"; query: SQLWrapper | string }

View source ↗

OrmColumnMetadataOf: OrmColumnMetadata & { type: Extract<OrmColumnType, { kind: K }> }

View source ↗

OrmColumnOptions: unknown

Members

  • comment?: string

  • default?: DefaultValueType<T> | () => DefaultValueType<T>

  • name?: string

  • nullable?: boolean

  • primaryKey?: boolean

  • transformer?: OrmValueTransformer

  • unique?: boolean

View source ↗

OrmColumnType: { increment?: boolean; kind: "integer"; size?: Exclude<OrmIntegerSizeType, "int64">; unsigned?: boolean } | { increment?: boolean; kind: "bigint"; mode: "number" | "bigint"; unsigned?: boolean } | { kind: "float"; precision?: number; scale?: number; unsigned?: boolean } | { kind: "double"; precision?: number; scale?: number; unsigned?: boolean } | { kind: "decimal"; mode: "string" | "number" | "bigint"; precision?: number; scale?: number; unsigned?: boolean } | { kind: "boolean" } | { kind: "char"; length: number } | { kind: "varchar"; length: number } | { kind: "text"; size?: OrmTextSizeType } | { fixed?: boolean; kind: "bytes"; size: number } | { fsp?: DatetimeFsp; kind: "datetime"; mode: "date" | "string" } | { generate?: boolean; kind: "uuid" } | { kind: "json" } | { kind: "enum"; values: Dictionary<unknown> | string[] }

View source ↗

OrmCredentials: OrmDiscreteCredentials | OrmUrlCredentials

View source ↗

SQL dialect spoken by the database. Determines syntax-level behavior (e.g. ON CONFLICT vs ON DUPLICATE KEY UPDATE, RETURNING vs lastInsertId). Adapters branch on this.

OrmDatabaseDialect: "sqlite" | "mysql"

View source ↗

Identifies a database backend as a (dialect, driver) pair. Dialect is the SQL syntax; driver is the specific client library / deployment surface used to reach it. Providers branch on the pair to know which connection setup applies.

OrmDatabaseType: { dialect: "sqlite"; driver: "d1" | "durable" | "better-sqlite" } | { dialect: "mysql"; driver: "planetscale" }

View source ↗

Extract the database-type entries that match the given dialect. Useful for typing adapter generics that work across all drivers of one dialect (e.g. the SQLite abstract base accepts all sqlite drivers).

OrmDatabaseTypeOfDialect: Extract<OrmDatabaseType, { dialect: TDialect }>

View source ↗

OrmDateEventMap: { [K in OrmDateEventType]: string[] }

View source ↗

OrmDateEventType: "create" | "update"

View source ↗

OrmDeleteResult: OrmMutationResult<TReturning>

View source ↗

The constructor type for an ORM entity class.

Every entity extends OrmTrackingEntity (directly or via OrmBaseEntity / OrmMutableBaseEntity), which installs the per-column change-tracking accessors the repository and hydrator rely on. Registration and data-access APIs are typed against this so a class that forgets to extend the base is rejected where it is registered, not at first use.

OrmEntityClass: Constructor<OrmTrackingEntity>

View source ↗

OrmEntityKey: Extract<NonFnKeys<T>, string>

View source ↗

OrmEntityKeys: (Extract<NonFnKeys<T>, string>)[]

View source ↗

Union type of all filter operators The discriminated union allows TypeScript to narrow types based on the 'type' field

OrmFilter: OrmEqualsFilter<T> | OrmNotEqualsFilter<T> | OrmGtFilter<T> | OrmGteFilter<T> | OrmLtFilter<T> | OrmLteFilter<T> | OrmInArrayFilter<T> | OrmNotInArrayFilter<T> | OrmBetweenFilter<T> | OrmNotBetweenFilter<T> | OrmLikeFilter | OrmNotLikeFilter | OrmIsNullFilter | OrmIsNotNullFilter | OrmExistsFilter | OrmNotExistsFilter | OrmNotFilter<T> | OrmAndFilter<T> | OrmOrFilter<T>

View source ↗

OrmFindOptionsOrder: OrmPartialEntityAs<T, "ASC" | "DESC">

View source ↗

Options for loading relations. Can be a boolean to load the relation, or nested options for loading nested relations.

OrmFindOptionsRelations: { [K in keyof T]?: T[K] extends ReadonlyArray<infer U> | undefined ? boolean | OrmFindOptionsRelations<U> : T[K] extends object | null | undefined ? boolean | OrmFindOptionsRelations<NonNullable<T[K]>> : never }
// Load user relation
{ user: true }

// Load user and their posts
{ user: { posts: true } }

// Load user, their posts, and comments on those posts
{ user: { posts: { comments: true } } }

View source ↗

OrmFindOptionsWhere: { [K in keyof T]?: OrmWhereFieldValue<T[K]> }

View source ↗

A column reference in an index declaration: a bare property name, or a name paired with a prefix length.

The bare-string form is the overwhelming majority and stays untouched, so adding prefix support changed no existing declaration.

OrmIndexColumn: string | OrmIndexColumnWithPrefix

View source ↗

OrmInsertResult: OrmMutationResult<TReturning> & { insertedId?: string | number | bigint }

View source ↗

OrmIntegerSizeType: "int8" | "int16" | "int24" | "int32" | "int64"

View source ↗

OrmListenerEventMap: { [K in OrmListenerEventType]: string[] }

View source ↗

OrmListenerEventType: "beforeInsert" | "afterInsert" | "beforeUpdate" | "afterUpdate" | "beforeDelete" | "afterDelete" | "afterLoad"

View source ↗

OrmMutationResult: unknown

Members

  • affectedRows?: number

    Rows the statement addressed. DIALECT CAVEAT for UPDATE: SQLite counts MATCHED rows, but MySQL (without CLIENT_FOUND_ROWS, which the PlanetScale HTTP driver cannot enable) counts CHANGED rows — an update that matches a row but leaves every value identical reports 0 there. Do not use affectedRows === 0 as an existence check on updates in portable code; query the row instead. Upsert counts are normalized (1 per operation on every dialect); deletes count matched rows everywhere.

  • raw?: unknown

  • returning?: TReturning[]

View source ↗

OrmPartialEntity: Partial<Pick<T, NonFnKeys<T>>>

View source ↗

OrmPartialEntityAs: Partial<Record<NonFnKeys<T>, V>>

View source ↗

OrmPrimaryAutoColumnMetadata: OrmPrimaryAutoSerialColumnMetadata | OrmPrimaryAutoUuidColumnMetadata

View source ↗

OrmPrimaryKeyInfo: { column: string; type: "single" } | { columns: string[]; name?: string; type: "composite" } | { column: string; type: "auto-uuid" } | { column: string; size?: OrmIntegerSizeType; type: "auto-serial" }

View source ↗

Type helper that represents the raw data form of an entity. Strips out methods, tracking fields, and other non-data properties, leaving only the plain data that would be stored in the database.

OrmRawData: { [K in keyof T]: T[K] }
class UserEntity extends OrmTrackingEntity {
    id: string;
    name: string;
    email: string;

    getName(): string { return this.name; }
}

// OrmRawData<UserEntity> would be:
// {
//     id: string;
//     name: string;
//     email: string;
// }

This type is used by OrmDatabase methods to accurately represent that they return plain JavaScript objects from the database, not entity instances with methods and tracking capabilities.

View source ↗

OrmRelationMetadata: { inverseSide?: string; joinColumn: string; nullable?: boolean; propertyKey: string; target: () => Constructor; type: "many-to-one" } | { inverseSide: string; propertyKey: string; target: () => Constructor; type: "one-to-many" } | { inverseSide?: string; joinColumn: string; nullable?: boolean; propertyKey: string; target: () => Constructor; type: "one-to-one" }

View source ↗

OrmSchemaBuilderDrizzleColumns: [any, ...any[]]

View source ↗

OrmSettings: OrmSettingsD1<AdapterType> | OrmSettingsDurableSQLite<AdapterType> | OrmSettingsPlanetScale<AdapterType> | OrmSettingsBetterSQLite<AdapterType>

View source ↗

OrmSettingsDurableSQLite: AdapterType extends keyof DurableSQLiteSettingsByAdapter ? DurableSQLiteSettingsByAdapter[AdapterType] : never

View source ↗

OrmTextSizeType: "tiny" | "medium" | "long"

View source ↗

OrmTimeSeriesFilter: unknown

Members

View source ↗

OrmTimeSeriesOptions: unknown

Members

View source ↗

Type definition for transaction callbacks

OrmTransactionCallback: () => Promise<void> | void

View source ↗

OrmTransactionResult: OrmTransactionSuccessResult<T> | OrmTransactionErrorResult

View source ↗

OrmUpdateResult: OrmMutationResult<TReturning>

View source ↗

Used to type inverseSide so it must name a real relation on the target entity — compile-checked, autocompleted, and updated by IDE rename-symbol rather than an unchecked string. If no relation keys can be identified for the target (e.g. it doesn't type its relations as entities), this falls back to string so the option stays usable instead of becoming never.

RelationKey: [RelationKeysOf<TargetType>] extends [never] ? string : RelationKeysOf<TargetType>

View source ↗

SQLiteDb: BaseSQLiteDatabase<SyncType, any, DrizzleFullSchema<AnySQLiteTable>, DrizzleSchema<AnySQLiteTable>>

View source ↗

SQLiteTx: SQLiteTransaction<"sync" | "async", any, DrizzleFullSchema<AnySQLiteTable>, DrizzleSchema<AnySQLiteTable>>

View source ↗