Interfaces
@system-inc/base-foundation · 515c140 · 76 symbols
DrizzleEmitted
Dual-output product of each builder primitive: the runtime drizzle value (column builder, constraint, etc.) AND its source-code representation. The same code path produces both, so they're structurally guaranteed to stay in sync.
helpers carries the set of drizzle-orm helper names the source
snippet uses (e.g. 'integer', 'primaryKey') so the assembled
file can emit a minimal import line.
Members
helpers:Set<string>runtime:Tsource:string
DrizzleMigrationConfig
Copy of the MigrationConfig type from Drizzle's migrator.
Members
journal:{ entries: DrizzleMigrationEntry[] }migrations:Record<string, string>
DrizzleMigrationEntry
Represents a single migration entry in the journal.
Members
breakpoints:booleanidx:numbertag:stringwhen:number
DrizzleTableQuery
Structural shape of a Drizzle relational query handle (db.query.{table}).
The concrete type Drizzle exposes is heavily generic and not part of the
public surface; we only need the two finders.
Members
findFirst(options?:unknown):Promise<unknown>findMany(options?:unknown):Promise<unknown>
HydrationOptions
Members
joins?:readonly (OrmMappedJoin<any>)[]Mapped joins from the find options. Each arrives in the raw row as a JSON-aggregated column and is hydrated onto its property.
maxDepth?:numberMaximum depth for hydrating nested relations
raw?:booleanIf true, returns raw objects without hydration
OrmAdapter
Members
adapterType:"drizzle"databaseType:OrmDatabaseTypesupportsInteractiveTransactions:booleantrueiftransaction(...)is supported (interactive read-write transactions);falseif onlywriteBatch(...)is available (D1). Portable code should preferwriteBatchand check this flag only when opportunistic use oftransactionis worthwhile.count(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<number>decrement(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number,additionalSet?:Record<string, unknown>):Promise<OrmUpdateResult<EntityType>>delete(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>):Promise<OrmDeleteResult<EntityType>>deleteBatch(metadata:OrmTableMetadata,conditions:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmDeleteResult<EntityType>>dispose():Promise<void>execute(query:string | SQLWrapper):Promise<any>executeRows(query:string | SQLWrapper):Promise<RowType[]>Runs a raw query and returns its result rows, normalized from the driver's shape into a plain array. See
OrmDatabase.executeRows.find(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<(OrmRawData<EntityType>)[]>findAndCount(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<[(OrmRawData<EntityType>)[], number]>findOne(metadata:OrmTableMetadata,options?:OrmFindOptions<EntityType>):Promise<OrmRawData<EntityType> | null>increment(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number,additionalSet?:Record<string, unknown>):Promise<OrmUpdateResult<EntityType>>insert(metadata:OrmTableMetadata,values:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmInsertResult<EntityType>>safeBatchSize(columnCount:number):numberReturns the largest chunk size that keeps a single statement's bound parameters under the adapter's safe limit. Use this when chunking a large input array in caller code (e.g. for an
IN (...)filter or a batched read) — pass the number of bound parameters each item contributes. Pass1for a list of scalar IDs.timeSeries(tableName:string,column:string,options:OrmTimeSeriesOptions<object>):Promise<OrmTimeSeriesResult[]>transaction(context:OrmDatabaseImpl,callback:(tx: OrmTransaction) => Promise<T>):Promise<T>Interactive read-write transaction. Throws on adapters where
supportsInteractiveTransactions === false(D1). For portable atomic writes, usewriteBatch.truncate(metadata:OrmTableMetadata):Promise<OrmDeleteResult<EntityType>>update(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmUpdateResult<EntityType>>updateBatch(metadata:OrmTableMetadata,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmUpdateResult<EntityType>>upsert(metadata:OrmTableMetadata,conditions:OrmPartialEntity<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>upsertBatch(metadata:OrmTableMetadata,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmInsertResult<EntityType>>writeBatch(operations:readonly OrmBatchOperation[]):Promise<OrmBatchResult>Execute a list of write operations atomically. Works on every adapter — D1 maps to
db.batch([...]), others wrap in a transaction. The portable primitive for atomic writes.
OrmAdapterOptions
Members
logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmAdapterProvider
Members
adapterType:AdapterTypedatabaseType:OrmDatabaseTypegetAdapter(database:string,settings:SettingsType,metadata:OrmTableMetadata[]):Adapter | Promise<Adapter>
OrmAdapterProviderBetterSQLite
extends OrmAdapterProvider<OrmSettingsBetterSQLite<AdapterType>, AdapterType>
Members
adapterType:AdapterTypedatabaseType:{ dialect: "sqlite"; driver: "better-sqlite" }getAdapter(database:string,settings:OrmSettingsBetterSQLite,metadata:OrmTableMetadata[]):OrmAdapter | Promise<OrmAdapter>
OrmAdapterProviderD1
extends OrmAdapterProvider<OrmSettingsD1<AdapterType>, AdapterType>
Members
adapterType:AdapterTypedatabaseType:{ dialect: "sqlite"; driver: "d1" }getAdapter(database:string,settings:OrmSettingsD1,metadata:OrmTableMetadata[]):OrmAdapter | Promise<OrmAdapter>
OrmAdapterProviderDurableSQLite
extends OrmAdapterProvider<OrmSettingsDurableSQLite<AdapterType>, AdapterType>
Members
adapterType:AdapterTypedatabaseType:{ dialect: "sqlite"; driver: "durable" }getAdapter(database:string,settings:OrmSettingsDurableSQLite,metadata:OrmTableMetadata[]):OrmAdapter | Promise<OrmAdapter>
OrmAdapterProviderPlanetScale
extends OrmAdapterProvider<OrmSettingsPlanetScale<AdapterType>, AdapterType>
Members
adapterType:AdapterTypedatabaseType:{ dialect: "mysql"; driver: "planetscale" }getAdapter(database:string,settings:OrmSettingsPlanetScale,metadata:OrmTableMetadata[]):OrmAdapter | Promise<OrmAdapter>
OrmAndFilter
AND logical operator: combines conditions that must all be true.
Generic over the operand value type so that, when used inside a typed
OrmFindOptionsWhere<T>, the wrapped filters are constrained to the
column's TS type. Mixing types — e.g. and(gte(<number>), lte(<Date>))
— becomes a type error.
OrmBatchResult
Result of OrmAdapter.writeBatch(...). results[i] corresponds to the
operation at the same index in the input. affectedRows is the sum
across all operations for convenience.
Members
affectedRows:numberresults:readonly (OrmInsertResult<object> | OrmUpdateResult<object> | OrmDeleteResult<object>)[]
OrmBetweenFilter
Between filter operator: field BETWEEN min AND max
Members
max:Tmin:Ttype:"between"
OrmColumnMetadata
Members
options?:OrmColumnOptionspropertyKey:stringtype:OrmColumnType
OrmDatabase
Members
name:stringcount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<number>Counts entities that match given options. Useful for pagination.
decrement(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>delete(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>):Promise<OrmDeleteResult<EntityType>>deleteBatch(target:Constructor<EntityType>,conditions:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmDeleteResult<EntityType>>dispose():Promise<void>execute(query:string | SQLWrapper):Promise<any>executeRows(query:string | SQLWrapper):Promise<RowType[]>Runs a raw query and returns its result rows in a dialect-independent shape — the adapter normalizes the driver's result (MySQL drivers resolve to
{ rows }, SQLite drivers to the array itself), so callers never branch on the backend.Use this for raw SELECTs. For driver-specific results (
insertId,affectedRows, DML statements), use execute.find(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<(OrmRawData<EntityType>)[]>findAndCount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<[(OrmRawData<EntityType>)[], number]>findOne(target:Constructor<EntityType>,options?:OrmFindOptions<EntityType>):Promise<OrmRawData<EntityType> | null>getAdapter():Promise<Pick<OrmAdapter, "adapterType" | "databaseType">>getEntities():OrmEntityClass[]All entity classes registered for this database.
getEntityByTableName(tableName:string):OrmEntityClass | undefinedResolves a registered entity class by its table name. Returns
undefinedif no registered entity maps to that table. Scoped to this database's configured entities, so it doubles as the allow-list for table-name-addressed access.getMetadata(target:OrmEntityClass):OrmTableMetadata | undefinedGets entity metadata for the given entity class or schema name.
getRepository(target:Constructor<EntityType>):OrmRepository<EntityType>hasMetadata(target:OrmEntityClass):booleanChecks if entity metadata exist for the given entity class, target name or table name.
increment(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>insert(target:Constructor<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>insertBatch(target:Constructor<EntityType>,values:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmInsertResult<EntityType>>safeBatchSize(columnCount:number):Promise<number>Returns the largest chunk size that keeps a single statement's bound parameters under the underlying adapter's safe limit. Use this when chunking a large input array in caller code (e.g. for an
IN (...)filter or a batched read). Pass1for a list of scalar IDs.timeSeries(target:Constructor<EntityType>,column:OrmEntityKey<EntityType>,options:OrmTimeSeriesOptions<EntityType>):Promise<OrmTimeSeriesResult[]>transaction(callback:(tx: OrmTransaction) => Promise<T>):Promise<T>truncate(target:Constructor<EntityType>,options:{ confirm: true }):Promise<OrmDeleteResult<EntityType>>Deletes every row in the table.
Requires the target entity to be marked
truncatable: truevia@OrmTable({ truncatable: true }). Tables that are not explicitly marked as truncatable will throw at runtime.The
confirm: trueflag must be passed at every call site to make the intent visible in code review — this method cannot be called without spelling out that a full-table wipe is intended.update(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmUpdateResult<EntityType>>updateBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmUpdateResult<EntityType>>upsert(target:Constructor<EntityType>,conditions:OrmPartialEntity<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>upsertBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmInsertResult<EntityType>>writeBatch(build:(batch: OrmDatabaseBatch) => void):Promise<OrmBatchResult>Atomically execute a batch of writes spanning one or more entity types. The portable primitive for atomic writes across all adapters (including D1).
OrmDatabaseBatch
Multi-entity batch builder used by OrmDatabase.writeBatch. The
entity class is inferred from each value's constructor — no need to
pre-declare which repository each call targets. Mixed-type arrays in
a single call are split into run-length-encoded groups so call order
is preserved (matters for FK-dependent writes that span entity types).
Members
delete(entity:EntityType | readonly EntityType[]):voiddeleteWhere(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>):voidQueue a delete by arbitrary conditions (the batch counterpart of
OrmDatabase.delete(target, conditions)). No entity lifecycle hooks run because no entity instances are involved.execute(query:string | SQLWrapper):voidQueue a raw write statement (built with the drizzle
sqltemplate) to run inside the same atomic batch — the escape hatch for bulk updates the entity API can't express (computed SET clauses, conditional shifts, increments). No entity lifecycle hooks run for it.insert(entity:EntityType | readonly EntityType[]):voidupdate(entity:EntityType | readonly EntityType[]):voidupsert(entity:EntityType | readonly EntityType[]):void
OrmDiscreteCredentials
Credentials for the database stored individually.
Members
database:stringDatabase name to connect to.
host:stringDatabase host.
password:stringDatabase password.
port?:numberDatabase port. Defaults to 3306.
type:"discrete"Credentials stored as individual fields.
username:stringDatabase username.
OrmDurableAdapter
extends OrmAdapter
Members
adapterType:"drizzle"databaseType:OrmDatabaseTypesupportsInteractiveTransactions:booleantrueiftransaction(...)is supported (interactive read-write transactions);falseif onlywriteBatch(...)is available (D1). Portable code should preferwriteBatchand check this flag only when opportunistic use oftransactionis worthwhile.count(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<number>decrement(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number,additionalSet?:Record<string, unknown>):Promise<OrmUpdateResult<EntityType>>delete(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>):Promise<OrmDeleteResult<EntityType>>deleteBatch(metadata:OrmTableMetadata,conditions:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmDeleteResult<EntityType>>dispose():Promise<void>execute(query:string | SQLWrapper):Promise<any>executeRows(query:string | SQLWrapper):Promise<RowType[]>Runs a raw query and returns its result rows, normalized from the driver's shape into a plain array. See
OrmDatabase.executeRows.find(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<(OrmRawData<EntityType>)[]>findAndCount(metadata:OrmTableMetadata,options?:OrmFindOptionsMany<EntityType>):Promise<[(OrmRawData<EntityType>)[], number]>findOne(metadata:OrmTableMetadata,options?:OrmFindOptions<EntityType>):Promise<OrmRawData<EntityType> | null>increment(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number,additionalSet?:Record<string, unknown>):Promise<OrmUpdateResult<EntityType>>insert(metadata:OrmTableMetadata,values:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmInsertResult<EntityType>>migrate():Promise<void>safeBatchSize(columnCount:number):numberReturns the largest chunk size that keeps a single statement's bound parameters under the adapter's safe limit. Use this when chunking a large input array in caller code (e.g. for an
IN (...)filter or a batched read) — pass the number of bound parameters each item contributes. Pass1for a list of scalar IDs.timeSeries(tableName:string,column:string,options:OrmTimeSeriesOptions<object>):Promise<OrmTimeSeriesResult[]>transaction(context:OrmDatabaseImpl,callback:(tx: OrmTransaction) => Promise<T>):Promise<T>Interactive read-write transaction. Throws on adapters where
supportsInteractiveTransactions === false(D1). For portable atomic writes, usewriteBatch.truncate(metadata:OrmTableMetadata):Promise<OrmDeleteResult<EntityType>>update(metadata:OrmTableMetadata,conditions:OrmFindOptionsWhere<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmUpdateResult<EntityType>>updateBatch(metadata:OrmTableMetadata,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmUpdateResult<EntityType>>upsert(metadata:OrmTableMetadata,conditions:OrmPartialEntity<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>upsertBatch(metadata:OrmTableMetadata,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmInsertResult<EntityType>>writeBatch(operations:readonly OrmBatchOperation[]):Promise<OrmBatchResult>Execute a list of write operations atomically. Works on every adapter — D1 maps to
db.batch([...]), others wrap in a transaction. The portable primitive for atomic writes.
OrmDurableDatabase
extends OrmDatabase
Members
name:stringcount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<number>Counts entities that match given options. Useful for pagination.
decrement(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>delete(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>):Promise<OrmDeleteResult<EntityType>>deleteBatch(target:Constructor<EntityType>,conditions:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmDeleteResult<EntityType>>dispose():Promise<void>execute(query:string | SQLWrapper):Promise<any>executeRows(query:string | SQLWrapper):Promise<RowType[]>Runs a raw query and returns its result rows in a dialect-independent shape — the adapter normalizes the driver's result (MySQL drivers resolve to
{ rows }, SQLite drivers to the array itself), so callers never branch on the backend.Use this for raw SELECTs. For driver-specific results (
insertId,affectedRows, DML statements), use execute.find(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<(OrmRawData<EntityType>)[]>findAndCount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<[(OrmRawData<EntityType>)[], number]>findOne(target:Constructor<EntityType>,options?:OrmFindOptions<EntityType>):Promise<OrmRawData<EntityType> | null>getAdapter():Promise<Pick<OrmAdapter, "adapterType" | "databaseType">>getEntities():OrmEntityClass[]All entity classes registered for this database.
getEntityByTableName(tableName:string):OrmEntityClass | undefinedResolves a registered entity class by its table name. Returns
undefinedif no registered entity maps to that table. Scoped to this database's configured entities, so it doubles as the allow-list for table-name-addressed access.getMetadata(target:OrmEntityClass):OrmTableMetadata | undefinedGets entity metadata for the given entity class or schema name.
getRepository(target:Constructor<EntityType>):OrmRepository<EntityType>hasMetadata(target:OrmEntityClass):booleanChecks if entity metadata exist for the given entity class, target name or table name.
increment(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>insert(target:Constructor<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>insertBatch(target:Constructor<EntityType>,values:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmInsertResult<EntityType>>migrate():Promise<void>safeBatchSize(columnCount:number):Promise<number>Returns the largest chunk size that keeps a single statement's bound parameters under the underlying adapter's safe limit. Use this when chunking a large input array in caller code (e.g. for an
IN (...)filter or a batched read). Pass1for a list of scalar IDs.timeSeries(target:Constructor<EntityType>,column:OrmEntityKey<EntityType>,options:OrmTimeSeriesOptions<EntityType>):Promise<OrmTimeSeriesResult[]>transaction(callback:(tx: OrmTransaction) => Promise<T>):Promise<T>truncate(target:Constructor<EntityType>,options:{ confirm: true }):Promise<OrmDeleteResult<EntityType>>Deletes every row in the table.
Requires the target entity to be marked
truncatable: truevia@OrmTable({ truncatable: true }). Tables that are not explicitly marked as truncatable will throw at runtime.The
confirm: trueflag must be passed at every call site to make the intent visible in code review — this method cannot be called without spelling out that a full-table wipe is intended.update(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmUpdateResult<EntityType>>updateBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmUpdateResult<EntityType>>upsert(target:Constructor<EntityType>,conditions:OrmPartialEntity<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>upsertBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmInsertResult<EntityType>>writeBatch(build:(batch: OrmDatabaseBatch) => void):Promise<OrmBatchResult>Atomically execute a batch of writes spanning one or more entity types. The portable primitive for atomic writes across all adapters (including D1).
OrmEqualsFilter
Equality filter operator: field = value
Members
type:"eq"value:T
OrmExistsFilter
Exists filter operator: checks if a subquery/condition returns any results
Members
type:"exists"value:any
OrmFindOptions
Defines a special criteria to find specific entity.
Members
comment?:stringAdds a comment with the supplied string in the generated query. This is helpful for debugging purposes, such as finding a specific query in the database server's logs, or for categorization using an APM product.
joins?:readonly (OrmMappedJoin<any>)[]Ad-hoc joins mapped onto properties of the entity, for related rows that are not declared relations (composite predicates, filtered loads). Compiled into the same SQL statement as the find, so they add no extra database round trips.
order?:Partial<Record<NonFnKeys<EntityType>, "ASC" | "DESC">>Order, in which entities should be ordered.
relations?:OrmFindOptionsRelations<EntityType>Indicates what relations of entity should be loaded (simplified left join form).
select?:OrmEntityKeys<EntityType>Specifies what columns should be retrieved.
where?:OrmFindOptionsWhere<EntityType> | (OrmFindOptionsWhere<EntityType>)[]Condition(s) to match entities. Fields within one object are ANDed; an array is OR across its elements.
OrmFindOptionsMany
Defines a special criteria to find specific entities.
extends OrmFindOptions<EntityType>
Members
comment?:stringAdds a comment with the supplied string in the generated query. This is helpful for debugging purposes, such as finding a specific query in the database server's logs, or for categorization using an APM product.
joins?:readonly (OrmMappedJoin<any>)[]Ad-hoc joins mapped onto properties of the entity, for related rows that are not declared relations (composite predicates, filtered loads). Compiled into the same SQL statement as the find, so they add no extra database round trips.
limit?:numberLimit (paginated) - max number of entities should be taken.
offset?:numberOffset (paginated) where from entities should be taken.
order?:Partial<Record<NonFnKeys<EntityType>, "ASC" | "DESC">>Order, in which entities should be ordered.
relations?:OrmFindOptionsRelations<EntityType>Indicates what relations of entity should be loaded (simplified left join form).
select?:OrmEntityKeys<EntityType>Specifies what columns should be retrieved.
where?:OrmFindOptionsWhere<EntityType> | (OrmFindOptionsWhere<EntityType>)[]Condition(s) to match entities. Fields within one object are ANDed; an array is OR across its elements.
OrmGteFilter
Greater than or equal filter operator: field >= value
Members
type:"gte"value:T
OrmGtFilter
Greater than filter operator: field > value
Members
type:"gt"value:T
OrmInArrayFilter
In array filter operator: field IN (values)
Members
type:"in"value:T[]
OrmIndexColumnWithPrefix
A column inside an index, optionally indexed by only its leading characters.
MySQL sizes an index key by each column's DECLARED width, so a
varchar(1024) in utf8mb4 reserves 4096 bytes and blows InnoDB's 3072-byte
ceiling on its own — the index simply cannot be created. A prefix indexes the
first N characters instead, which is what makes long titles, paths, and
subjects indexable at all.
A prefix still serves equality and leading-wildcard-free LIKE, and still
orders rows; it cannot serve a covering-index-only read, because the stored
key is truncated.
Members
column:stringprefixLength:numberNumber of leading CHARACTERS to index (not bytes — MySQL's
col(n)counts characters, and the byte cost isn × 4under utf8mb4).
OrmIndexKeyLengthFinding
Members
columns:string[]estimatedBytes:numberindexName:stringlargestColumns:({ bytes: number; name: string })[]The subset of columns responsible for most of the weight, widest first.
reason:"TooLong" | "TextWithoutPrefix"tableName:string
OrmIsNotNullFilter
Is not null filter operator: field IS NOT NULL
Members
type:"isNotNull"
OrmIsNullFilter
Is null filter operator: field IS NULL
Members
type:"isNull"
OrmJoinColumnOptions
Options for the @OrmJoinColumn decorator.
Members
name?:stringName of the column in the database
nullable?:booleanWhether this column can be NULL
referencedColumnName?:stringName of the column in the referenced entity to which this column refers Default is the primary key of the referenced table
OrmLikeFilter
Like filter operator for pattern matching: field LIKE pattern Use % for wildcard (e.g., '%test%' matches any string containing 'test') Case sensitivity depends on database collation (MySQL/SQLite default to case-insensitive)
Members
pattern:stringtype:"like"
OrmLteFilter
Less than or equal filter operator: field <= value
Members
type:"lte"value:T
OrmLtFilter
Less than filter operator: field < value
Members
type:"lt"value:T
OrmManyToOneOptions
Options for the @OrmManyToOne decorator. TargetType is inferred from the
decorator's () => Target thunk so inverseSide is checked against the
target's relation properties.
Members
inverseSide?:RelationKey<TargetType>The relation on the target entity that points back to this entity.
joinColumn?:stringThe column in this table that references the foreign entity If not specified, will be inferred as
${propertyKey}Idnullable?:booleanWhether this relation can be null
OrmMappedJoin
An ad-hoc join mapped onto a property of the found entity — the escape hatch for loading related rows that are not declared relations (composite predicates, filtered loads, cross-cutting lookups) without paying an extra database round trip.
Each mapped join compiles into a correlated JSON-aggregation subquery
inside the same SQL statement as the main find, so a find with any
number of mapped joins is still a single round trip. The JSON result
is hydrated into entity instances and assigned to property on the
parent.
Limitations: where values may be plain values, scalar Orm filters
(equals/notEquals/in/notIn/gt/gte/lt/lte/between/notBetween/like/
notLike/isNull/isNotNull), or parentColumn() references — composite
and/or/not filters are not supported. Result ordering inside a
many join is not guaranteed; sort in memory if it matters.
Members
entity:Constructor<JoinedType>The entity to join. Must be a registered @OrmTable.
joins?:readonly (OrmMappedJoin<any>)[]Nested mapped joins, with this join's entity as their parent.
property:stringThe property on the parent entity the result is assigned to.
relations?:OrmFindOptionsRelations<JoinedType>Declared relations of the joined entity to load along with it, nested into the same subquery.
type:"one" | "many"Whether the property receives a single entity (or null) or an array of entities.
where:Dictionary<unknown>Conditions on the joined entity, keyed by property key. All conditions are ANDed. Use parentColumn to reference columns of the parent entity (the join predicate); other values are constants or scalar Orm filters.
OrmNotBetweenFilter
Not between filter operator: field NOT BETWEEN min AND max
Members
max:Tmin:Ttype:"notBetween"
OrmNotEqualsFilter
Not equal filter operator: field != value
Members
type:"ne"value:T
OrmNotExistsFilter
Not exists filter operator: checks if a subquery/condition returns no results
Members
type:"notExists"value:any
OrmNotFilter
NOT logical operator: negates a condition.
Generic over the operand value type — see OrmAndFilter for rationale.
OrmNotInArrayFilter
Not in array filter operator: field NOT IN (values)
Members
type:"notIn"value:T[]
OrmNotLikeFilter
Not like filter operator: field NOT LIKE pattern Use % for wildcard (e.g., '%test%' excludes any string containing 'test') Case sensitivity depends on database collation (MySQL/SQLite default to case-insensitive)
Members
pattern:stringtype:"notLike"
OrmOneToManyOptions
Options for the @OrmOneToMany decorator.
Members
inverseSide:RelationKey<TargetType>The relation on the target entity that points back to this entity.
OrmOneToOneOptions
Options for the @OrmOneToOne decorator.
Members
inverseSide?:RelationKey<TargetType>The relation on the target entity that points back to this entity.
joinColumn?:stringThe column in this table that references the foreign entity If not specified, will be inferred as
${propertyKey}Idnullable?:booleanWhether this relation can be null
OrmOrFilter
OR logical operator: combines conditions where at least one must be true.
Generic over the operand value type — see OrmAndFilter for rationale.
OrmPaginatedFindOptions
Members
joins?:readonly (OrmMappedJoin<any>)[]Mapped joins to load with each item (see OrmMappedJoin) — compiled into the same statement as the find, no extra round trips.
order?:Partial<Record<NonFnKeys<EntityType>, "ASC" | "DESC">>pagination?:PaginationInput | OrmPaginationInputThe wire
PaginationInput(or a@PaginationInputForsubclass) can be passed directly —ormPaginatedFindbridges it toOrmPaginationInputinternally, applying any declared allowlists. Pass anOrmPaginationInputyou bridged yourself only when the resolver needsscopeWhere/narrowing first.relations?:OrmFindOptionsRelations<EntityType>repository:OrmRepository<EntityType>where?:OrmFindOptionsWhere<EntityType>
OrmParentColumnReference
A reference to a column on the parent entity of a mapped join. Used as
a value inside OrmMappedJoin.where to express the join
predicate, e.g. { accountId: parentColumn('accountId') }.
column is the property key on the parent entity (database column
names are resolved from the parent's metadata).
Members
column:stringtype:"parentColumn"
OrmPrimaryAutoSerialColumnMetadata
Members
propertyKey:stringsize?:OrmIntegerSizeTypestrategy:"serial"
OrmPrimaryAutoUuidColumnMetadata
Members
propertyKey:stringstrategy:"uuid"
OrmPrimaryKeyMetadata
Members
columns:string[]options?:OrmPrimaryKeyOptions
OrmPrimaryKeyOptions
Members
name?:string
OrmReadonlyDatabase
Members
name:stringcount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<number>Counts entities that match given options. Useful for pagination.
find(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<readonly (Readonly<OrmRawData<EntityType>>)[]>findAndCount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<[readonly (Readonly<OrmRawData<EntityType>>)[], number]>findOne(target:Constructor<EntityType>,options?:OrmFindOptions<EntityType>):Promise<Readonly<OrmRawData<EntityType>> | null>getMetadata(target:Constructor):OrmTableMetadata | undefinedGets entity metadata for the given entity class or schema name.
getRepository(target:Constructor<EntityType>):OrmReadonlyRepository<EntityType>hasMetadata(target:Constructor):booleanChecks if entity metadata exist for the given entity class, target name or table name.
OrmReadonlyRepository
Members
db:OrmDatabaseImpl<OrmSettings<"drizzle">>tableName:stringtarget:Constructor<EntityType>count(options?:OrmFindOptionsMany<EntityType>):Promise<number>Counts entities that match given options. Useful for pagination.
find(options?:OrmFindOptionsMany<EntityType>):Promise<readonly (Readonly<EntityType>)[]>Finds entities that match given find options.
findAndCount(options?:OrmFindOptionsMany<EntityType>):Promise<[readonly (Readonly<EntityType>)[], number]>Finds entities that match given find options. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).
findOne(options?:OrmFindOptions<EntityType>):Promise<Readonly<EntityType> | null>Finds first entity by a given find options. If entity was not found in the database - returns null.
OrmRepositoryBatch
Callback-passed batch builder, mirroring the repository API. Each method
queues an operation (no I/O) and runs the appropriate before* hooks
synchronously. The repository's writeBatch submits the queued
operations atomically and then runs the matching after* hooks.
Members
delete(entity:EntityType | readonly EntityType[]):voidinsert(entity:EntityType | readonly EntityType[]):voidupdate(entity:EntityType | readonly EntityType[]):voidupsert(entity:EntityType | readonly EntityType[]):void
OrmSchemaBuilder
Members
createSchema(metadata:OrmTableMetadata[]):void
OrmSettingsBase
Members
adapterType:AdapterTypeThe type of ORM adapter to use.
entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.inheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmSettingsBetterSQLite
extends OrmSettingsBase<AdapterType>
Members
adapter:Constructor<OrmAdapterProviderBetterSQLite<AdapterType>>adapterType:AdapterTypeThe type of ORM adapter to use.
databaseType:{ dialect: "sqlite"; driver: "better-sqlite" }entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.filePath:stringinheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmSettingsD1
extends OrmSettingsBase<AdapterType>
Members
adapter:Constructor<OrmAdapterProviderD1<AdapterType>>adapterType:AdapterTypeThe type of ORM adapter to use.
binding:stringdatabaseType:{ dialect: "sqlite"; driver: "d1" }entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.inheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmSettingsDurableSQLiteBase
extends OrmSettingsBase<AdapterType>
Members
adapter:Constructor<OrmAdapterProviderDurableSQLite<AdapterType>>adapterType:AdapterTypeThe type of ORM adapter to use.
databaseType:{ dialect: "sqlite"; driver: "durable" }entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.inheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmSettingsDurableSQLiteDrizzle
extends OrmSettingsDurableSQLiteBase<"drizzle">
Members
adapter:Constructor<OrmAdapterProviderDurableSQLite<"drizzle">>adapterType:"drizzle"The type of ORM adapter to use.
databaseType:{ dialect: "sqlite"; driver: "durable" }entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.inheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
migrations:DrizzleMigrationConfigDrizzle migration bundle (the default export of drizzle-kit's generated
migrations.js). Required for durable DOs because the DO runs migrations against its own SQLite at boot — there's no external migration runner.released:string[]Tag list from
release.ts. The runtime migration runner refuses to run any migration whose tag isn't in this list on non-Development environments — defense in depth in casebase deploy's pre-flight check was somehow bypassed.
OrmSettingsPlanetScale
extends OrmSettingsBase<AdapterType>
Members
adapter:Constructor<OrmAdapterProviderPlanetScale<AdapterType>>adapterType:AdapterTypeThe type of ORM adapter to use.
credentials?:OrmCredentialsdatabaseType:{ dialect: "mysql"; driver: "planetscale" }entities?:OrmEntityClass[]The entities to load for the Worker.
This represents the database tables that are specific to your Worker separate of the module tables.
This should be each individual entity class.
externalEntities?:OrmEntityClass[]Entities this worker USES for queries but does NOT own — their schema is migrated by someone else (a sibling worker sharing the database). They are built into the runtime query schema, but excluded from migration generation (
schema:diff/schema:check) and theschema:synctable scope. The direct-registration equivalent of a module registered withexternalSchema: true.inheritSchema?:stringInherit the entity set from another configured ORM database, by name (e.g. a read-replica that targets the same schema). The inherited entities are merged with this config's own
entities(deduplicated), and resolution is transitive. Only the schema is inherited — this config keeps its own adapter, dialect, and credentials.logging?:booleanEnable or disable logging of SQL queries.
Defaults to false.
OrmTableIndexMetadata
Members
columns:OrmIndexColumn[]The indexed columns. Usually plain property names; an entry may carry a
prefixLengthwhen the column is too wide to index whole (seeOrmIndexColumn).name?:stringoptions?:OrmTableIndexOptions
OrmTableIndexOptions
Members
dialect?:{ mysql?: { clustered?: boolean } }unique?:boolean
OrmTableMetadata
Members
columns:OrmColumnMetadata[]dateColumns:OrmDateEventMapindexes:OrmTableIndexMetadata[]joinColumns:Dictionary<OrmJoinColumnOptions>listeners:OrmListenerEventMapname:stringoptions?:OrmTableOptionsprimaryKey?:OrmPrimaryKeyInforelations:OrmRelationMetadata[]uniqueConstraints:OrmTableUniqueMetadata[]
OrmTableOptions
Members
comment?:stringtruncatable?:booleanWhether this table may be wiped via
truncate().Defaults to
false. Tables that are not explicitly marked as truncatable will throw at runtime whentruncate()is called, preventing accidental full-table deletion.Typically only used for test fixtures, ephemeral caches, and tables whose rows are regenerated from a source of truth.
OrmTableUniqueMetadata
Members
columns:string[]name?:string
OrmTimeSeriesResult
Members
bucket:stringfilterKeys:({ count: number; key: string })[]total:number
OrmTransaction
extends Omit<OrmDatabase, "transaction" | "dispose">
Members
name:stringcount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<number>Counts entities that match given options. Useful for pagination.
decrement(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>delete(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>):Promise<OrmDeleteResult<EntityType>>deleteBatch(target:Constructor<EntityType>,conditions:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmDeleteResult<EntityType>>execute(query:string | SQLWrapper):Promise<any>executeRows(query:string | SQLWrapper):Promise<RowType[]>Runs a raw query and returns its result rows in a dialect-independent shape — the adapter normalizes the driver's result (MySQL drivers resolve to
{ rows }, SQLite drivers to the array itself), so callers never branch on the backend.Use this for raw SELECTs. For driver-specific results (
insertId,affectedRows, DML statements), use execute.find(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<(OrmRawData<EntityType>)[]>findAndCount(target:Constructor<EntityType>,options?:OrmFindOptionsMany<EntityType>):Promise<[(OrmRawData<EntityType>)[], number]>findOne(target:Constructor<EntityType>,options?:OrmFindOptions<EntityType>):Promise<OrmRawData<EntityType> | null>getAdapter():Promise<Pick<OrmAdapter, "adapterType" | "databaseType">>getEntities():OrmEntityClass[]All entity classes registered for this database.
getEntityByTableName(tableName:string):OrmEntityClass | undefinedResolves a registered entity class by its table name. Returns
undefinedif no registered entity maps to that table. Scoped to this database's configured entities, so it doubles as the allow-list for table-name-addressed access.getMetadata(target:OrmEntityClass):OrmTableMetadata | undefinedGets entity metadata for the given entity class or schema name.
getRepository(target:Constructor<EntityType>):OrmRepository<EntityType>hasMetadata(target:OrmEntityClass):booleanChecks if entity metadata exist for the given entity class, target name or table name.
increment(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,column:keyof EntityType & string,value?:number):Promise<OrmUpdateResult<EntityType>>insert(target:Constructor<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>insertBatch(target:Constructor<EntityType>,values:readonly (Partial<Pick<EntityType, NonFnKeys<EntityType>>>)[]):Promise<OrmInsertResult<EntityType>>onFailure(callback:OrmTransactionCallback):voidRegister a callback to be executed after transaction failure/rollback
onSuccess(callback:OrmTransactionCallback):voidRegister a callback to be executed after successful transaction commit
rollback():neverForces the transaction to fail and rollback. This will execute all failure callbacks registered with
onFailure.safeBatchSize(columnCount:number):Promise<number>Returns the largest chunk size that keeps a single statement's bound parameters under the underlying adapter's safe limit. Use this when chunking a large input array in caller code (e.g. for an
IN (...)filter or a batched read). Pass1for a list of scalar IDs.timeSeries(target:Constructor<EntityType>,column:OrmEntityKey<EntityType>,options:OrmTimeSeriesOptions<EntityType>):Promise<OrmTimeSeriesResult[]>truncate(target:Constructor<EntityType>,options:{ confirm: true }):Promise<OrmDeleteResult<EntityType>>Deletes every row in the table.
Requires the target entity to be marked
truncatable: truevia@OrmTable({ truncatable: true }). Tables that are not explicitly marked as truncatable will throw at runtime.The
confirm: trueflag must be passed at every call site to make the intent visible in code review — this method cannot be called without spelling out that a full-table wipe is intended.update(target:Constructor<EntityType>,conditions:OrmFindOptionsWhere<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmUpdateResult<EntityType>>updateBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmUpdateResult<EntityType>>upsert(target:Constructor<EntityType>,conditions:OrmPartialEntity<EntityType>,values:OrmPartialEntity<EntityType>):Promise<OrmInsertResult<EntityType>>upsertBatch(target:Constructor<EntityType>,operations:readonly ({ conditions: OrmPartialEntity<EntityType>; values: OrmPartialEntity<EntityType> })[]):Promise<OrmInsertResult<EntityType>>writeBatch(build:(batch: OrmDatabaseBatch) => void):Promise<OrmBatchResult>Atomically execute a batch of writes spanning one or more entity types. The portable primitive for atomic writes across all adapters (including D1).
OrmTransactionBaseResult
Members
onFailure:OrmTransactionCallback[]onSuccess:OrmTransactionCallback[]
OrmTransactionErrorResult
extends OrmTransactionBaseResult
Members
kind:"error"onFailure:OrmTransactionCallback[]onSuccess:OrmTransactionCallback[]txError:unknown
OrmTransactionSuccessResult
extends OrmTransactionBaseResult
Members
kind:"success"onFailure:OrmTransactionCallback[]onSuccess:OrmTransactionCallback[]txResult:T
OrmUrlCredentials
Credentials for the database formatted in a URL.
Members
type:"url"Credentials stored in a URL.
url:stringThe url parameter that should contain all credentials required to connect to the database.
The format of the url parameter is: [connector]://[user_name]:[password]@[host]:[port]/[database]?[arguments]
[connector] can be one of the following: mysql: MySQL database. planetscale-serverless: PlanetScale Serverless database.
[user_name] is the username to connect to the database. [password] is the password to connect to the database. [host] is the host of the database. [port] is the port of the database. [database] is the name of the database to connect to. [arguments] is a key/value pair list of arguments to pass to the database connector.
OrmValueTransformer
Interface for transforming values between entity and database representations.
Members
from(value:DatabaseType):EntityTypeTransforms the value from the database to the entity property. Called during entity hydration.
to(value:EntityType):DatabaseTypeTransforms the value from the entity property to the database. Called during insert/update operations.
TimezoneOffsetSegment
Members
endEpochSec:numberExclusive segment end.
offsetMinutes:numberstartEpochSec:numberInclusive segment start (clamped to the queried range).