metal-orm 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -37
- package/dist/decorators/index.cjs +152 -23
- package/dist/decorators/index.cjs.map +1 -1
- package/dist/decorators/index.d.cts +1 -1
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +152 -23
- package/dist/decorators/index.js.map +1 -1
- package/dist/index.cjs +322 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -4
- package/dist/index.d.ts +53 -4
- package/dist/index.js +316 -115
- package/dist/index.js.map +1 -1
- package/dist/{select-BKZrMRCQ.d.cts → select-BPCn6MOH.d.cts} +183 -64
- package/dist/{select-BKZrMRCQ.d.ts → select-BPCn6MOH.d.ts} +183 -64
- package/package.json +2 -1
- package/src/core/ast/aggregate-functions.ts +50 -4
- package/src/core/ast/expression-builders.ts +22 -15
- package/src/core/ast/expression-nodes.ts +6 -0
- package/src/core/ddl/introspect/functions/postgres.ts +2 -6
- package/src/core/dialect/abstract.ts +12 -8
- package/src/core/dialect/mssql/functions.ts +24 -15
- package/src/core/dialect/postgres/functions.ts +33 -24
- package/src/core/dialect/sqlite/functions.ts +19 -12
- package/src/core/functions/datetime.ts +2 -1
- package/src/core/functions/numeric.ts +2 -1
- package/src/core/functions/standard-strategy.ts +52 -12
- package/src/core/functions/text.ts +2 -1
- package/src/core/functions/types.ts +8 -8
- package/src/index.ts +5 -4
- package/src/orm/domain-event-bus.ts +43 -25
- package/src/orm/entity-meta.ts +40 -0
- package/src/orm/execution-context.ts +6 -0
- package/src/orm/hydration-context.ts +6 -4
- package/src/orm/orm-session.ts +35 -24
- package/src/orm/orm.ts +10 -10
- package/src/orm/query-logger.ts +15 -0
- package/src/orm/runtime-types.ts +60 -2
- package/src/orm/transaction-runner.ts +7 -0
- package/src/orm/unit-of-work.ts +1 -0
- package/src/query-builder/insert-query-state.ts +13 -3
- package/src/query-builder/select-helpers.ts +50 -0
- package/src/query-builder/select.ts +122 -30
- package/src/query-builder/update-query-state.ts +31 -9
- package/src/schema/types.ts +16 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { O as OperandNode, C as ColumnRef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode,
|
|
2
|
-
export { a8 as CascadeMode, Z as CheckConstraint,
|
|
1
|
+
import { L as LiteralNode, O as OperandNode, C as ColumnRef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, b as LogicalExpressionNode, N as NullExpressionNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, h as ColumnDef, T as TableRef, i as TableDef, j as InsertQueryNode, k as InsertCompiler, l as CompiledQuery, D as Dialect, m as DialectKey, U as UpdateQueryNode, n as UpdateCompiler, o as DeleteQueryNode, p as DeleteCompiler, q as CompilerContext, r as ForeignKeyReference, s as IndexColumn, t as IndexDef, u as DbExecutor, H as HydrationPlan, v as NamingStrategy, R as RelationMap, w as EntityContext, x as Entity, y as HasManyRelation, z as HasOneRelation, A as BelongsToRelation, G as BelongsToManyRelation, K as HasManyCollection, M as BelongsToReference, P as ManyToManyCollection, Q as OrmSession, V as SelectQueryBuilder, X as ExecutionContext, Y as HydrationContext } from './select-BPCn6MOH.cjs';
|
|
2
|
+
export { aI as AnyDomainEvent, a8 as CascadeMode, Z as CheckConstraint, af as ColumnToTs, a1 as ColumnType, av as DbExecutorFactory, a4 as DefaultValue, aH as DomainEvent, aA as DomainEventBus, ay as DomainEventHandler, aC as EntityStatus, aw as ExternalTransaction, aK as HasDomainEvents, ah as HasOneReference, ar as HydrationMetadata, ap as HydrationPivotPlan, aq as HydrationRelationPlan, ag as InferRow, az as InitialHandlers, ax as Orm, aJ as OrmDomainEvent, as as OrmInterceptor, au as OrmOptions, at as OrmSessionOptions, aL as QueryLogEntry, aM as QueryLogger, aO as QueryResult, a3 as RawDefaultValue, a2 as ReferentialAction, aF as RelationChange, aG as RelationChangeEntry, a9 as RelationDef, aE as RelationKey, a6 as RelationKinds, ae as RelationTargetTable, a7 as RelationType, aQ as SimpleQueryRunner, $ as TableHooks, _ as TableOptions, aD as TrackedEntity, aB as addDomainEvent, ac as belongsTo, ad as belongsToMany, a5 as col, ai as createColumn, aR as createExecutorFromQueryRunner, aj as createLiteral, aN as createQueryLoggingExecutor, a0 as defineTable, aa as hasMany, ab as hasOne, am as isCaseExpressionNode, ao as isExpressionSelectionNode, al as isFunctionNode, ak as isOperandNode, an as isWindowFunctionNode, aP as rowsToQueryResult } from './select-BPCn6MOH.cjs';
|
|
3
3
|
|
|
4
|
+
type LiteralValue = LiteralNode['value'];
|
|
5
|
+
type ValueOperandInput = OperandNode | LiteralValue;
|
|
4
6
|
/**
|
|
5
7
|
* Converts a primitive or existing operand into an operand node
|
|
6
8
|
* @param value - Value or operand to normalize
|
|
7
9
|
* @returns OperandNode representing the value
|
|
8
10
|
*/
|
|
9
|
-
declare const valueToOperand: (value:
|
|
11
|
+
declare const valueToOperand: (value: ValueOperandInput) => OperandNode;
|
|
12
|
+
declare const isValueOperandInput: (value: unknown) => value is ValueOperandInput;
|
|
10
13
|
declare const columnOperand: (col: ColumnRef | ColumnNode) => ColumnNode;
|
|
11
14
|
/**
|
|
12
15
|
* Creates an equality expression (left = right)
|
|
@@ -221,6 +224,30 @@ declare const sum: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
|
221
224
|
* @returns Function node with AVG
|
|
222
225
|
*/
|
|
223
226
|
declare const avg: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
227
|
+
/**
|
|
228
|
+
* Creates a MIN function expression
|
|
229
|
+
* @param col - Column to take the minimum of
|
|
230
|
+
* @returns Function node with MIN
|
|
231
|
+
*/
|
|
232
|
+
declare const min: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a MAX function expression
|
|
235
|
+
* @param col - Column to take the maximum of
|
|
236
|
+
* @returns Function node with MAX
|
|
237
|
+
*/
|
|
238
|
+
declare const max: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
239
|
+
type GroupConcatOrderByInput = {
|
|
240
|
+
column: ColumnRef | ColumnNode;
|
|
241
|
+
direction?: OrderDirection;
|
|
242
|
+
};
|
|
243
|
+
type GroupConcatOptions = {
|
|
244
|
+
separator?: ValueOperandInput;
|
|
245
|
+
orderBy?: GroupConcatOrderByInput[];
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Aggregates grouped strings into a single value.
|
|
249
|
+
*/
|
|
250
|
+
declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => FunctionNode;
|
|
224
251
|
|
|
225
252
|
/**
|
|
226
253
|
* Visitor for expression nodes
|
|
@@ -286,6 +313,18 @@ declare const toColumnRef: (col: ColumnRef | ColumnDef) => ColumnRef;
|
|
|
286
313
|
*/
|
|
287
314
|
declare const toTableRef: (table: TableRef | TableDef) => TableRef;
|
|
288
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Build a typed selection map from a TableDef.
|
|
318
|
+
*/
|
|
319
|
+
declare function sel<TTable extends TableDef, K extends keyof TTable['columns'] & string>(table: TTable, ...cols: K[]): Record<K, TTable['columns'][K]>;
|
|
320
|
+
type Ctor<T> = {
|
|
321
|
+
new (...args: any[]): T;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Build a typed selection map from an entity constructor.
|
|
325
|
+
*/
|
|
326
|
+
declare function esel<TEntity, K extends keyof TEntity & string>(entity: Ctor<TEntity>, ...props: K[]): Record<K, ColumnDef>;
|
|
327
|
+
|
|
289
328
|
/**
|
|
290
329
|
* Maintains immutable state for building INSERT queries
|
|
291
330
|
*/
|
|
@@ -1181,12 +1220,22 @@ declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _rel
|
|
|
1181
1220
|
declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, any>>>;
|
|
1182
1221
|
declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
|
|
1183
1222
|
|
|
1223
|
+
/**
|
|
1224
|
+
* Metadata stored on entity instances for ORM internal use
|
|
1225
|
+
* @typeParam TTable - Table definition type
|
|
1226
|
+
*/
|
|
1184
1227
|
interface EntityMeta<TTable extends TableDef> {
|
|
1228
|
+
/** Entity context */
|
|
1185
1229
|
ctx: EntityContext;
|
|
1230
|
+
/** Table definition */
|
|
1186
1231
|
table: TTable;
|
|
1232
|
+
/** Relations that should be loaded lazily */
|
|
1187
1233
|
lazyRelations: (keyof RelationMap<TTable>)[];
|
|
1234
|
+
/** Cache for relation promises */
|
|
1188
1235
|
relationCache: Map<string, Promise<any>>;
|
|
1236
|
+
/** Hydration data for relations */
|
|
1189
1237
|
relationHydration: Map<string, Map<string, any>>;
|
|
1238
|
+
/** Relation wrapper instances */
|
|
1190
1239
|
relationWrappers: Map<string, unknown>;
|
|
1191
1240
|
}
|
|
1192
1241
|
|
|
@@ -1303,4 +1352,4 @@ interface MssqlClientLike {
|
|
|
1303
1352
|
}
|
|
1304
1353
|
declare function createMssqlExecutor(client: MssqlClientLike): DbExecutor;
|
|
1305
1354
|
|
|
1306
|
-
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, type ColumnDiff, ColumnNode, ColumnRef, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, EntityContext, ExecutionContext, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, HasManyCollection, HasManyRelation, HasOneRelation, HydrationContext, HydrationPlan, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, LogicalExpressionNode, ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, NullExpressionNode, OperandNode, type OperandVisitor, OrmSession, type PostgresClientLike, PostgresDialect, RelationMap, type RenderColumnOptions, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, type SqliteClientLike, SqliteDialect, type SynchronizeOptions, TableDef, TableRef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, abs, acos, and, ascii, asin, atan, atan2, avg, between, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, columnOperand, concat, concatWs, cos, cot, count, createEntityFromRow, createEntityProxy, createMssqlExecutor, createMysqlExecutor, createPostgresExecutor, createSqliteExecutor, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, degrees, denseRank, diffSchema, endOfMonth, eq, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getSchemaIntrospector, gt, gte, hydrateRows, inList, instr, introspectSchema, isNotNull, isNull, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, mod, month, neq, notBetween, notExists, notInList, notLike, now, ntile, or, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rpad, rtrim, sign, sin, space, sqrt, substr, sum, synchronizeSchema, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
1355
|
+
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, type ColumnDiff, ColumnNode, ColumnRef, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, EntityContext, ExecutionContext, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, type GroupConcatOptions, HasManyCollection, HasManyRelation, HasOneRelation, HydrationContext, HydrationPlan, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, type LiteralValue, LogicalExpressionNode, ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, NullExpressionNode, OperandNode, type OperandVisitor, OrmSession, type PostgresClientLike, PostgresDialect, RelationMap, type RenderColumnOptions, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, type SqliteClientLike, SqliteDialect, type SynchronizeOptions, TableDef, TableRef, TypeScriptGenerator, UpdateQueryBuilder, type ValueOperandInput, WindowFunctionNode, abs, acos, and, ascii, asin, atan, atan2, avg, between, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, columnOperand, concat, concatWs, cos, cot, count, createEntityFromRow, createEntityProxy, createMssqlExecutor, createMysqlExecutor, createPostgresExecutor, createSqliteExecutor, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, degrees, denseRank, diffSchema, endOfMonth, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getSchemaIntrospector, groupConcat, gt, gte, hydrateRows, inList, instr, introspectSchema, isNotNull, isNull, isValueOperandInput, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, neq, notBetween, notExists, notInList, notLike, now, ntile, or, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rpad, rtrim, sel, sign, sin, space, sqrt, substr, sum, synchronizeSchema, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { O as OperandNode, C as ColumnRef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode,
|
|
2
|
-
export { a8 as CascadeMode, Z as CheckConstraint,
|
|
1
|
+
import { L as LiteralNode, O as OperandNode, C as ColumnRef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, b as LogicalExpressionNode, N as NullExpressionNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, h as ColumnDef, T as TableRef, i as TableDef, j as InsertQueryNode, k as InsertCompiler, l as CompiledQuery, D as Dialect, m as DialectKey, U as UpdateQueryNode, n as UpdateCompiler, o as DeleteQueryNode, p as DeleteCompiler, q as CompilerContext, r as ForeignKeyReference, s as IndexColumn, t as IndexDef, u as DbExecutor, H as HydrationPlan, v as NamingStrategy, R as RelationMap, w as EntityContext, x as Entity, y as HasManyRelation, z as HasOneRelation, A as BelongsToRelation, G as BelongsToManyRelation, K as HasManyCollection, M as BelongsToReference, P as ManyToManyCollection, Q as OrmSession, V as SelectQueryBuilder, X as ExecutionContext, Y as HydrationContext } from './select-BPCn6MOH.js';
|
|
2
|
+
export { aI as AnyDomainEvent, a8 as CascadeMode, Z as CheckConstraint, af as ColumnToTs, a1 as ColumnType, av as DbExecutorFactory, a4 as DefaultValue, aH as DomainEvent, aA as DomainEventBus, ay as DomainEventHandler, aC as EntityStatus, aw as ExternalTransaction, aK as HasDomainEvents, ah as HasOneReference, ar as HydrationMetadata, ap as HydrationPivotPlan, aq as HydrationRelationPlan, ag as InferRow, az as InitialHandlers, ax as Orm, aJ as OrmDomainEvent, as as OrmInterceptor, au as OrmOptions, at as OrmSessionOptions, aL as QueryLogEntry, aM as QueryLogger, aO as QueryResult, a3 as RawDefaultValue, a2 as ReferentialAction, aF as RelationChange, aG as RelationChangeEntry, a9 as RelationDef, aE as RelationKey, a6 as RelationKinds, ae as RelationTargetTable, a7 as RelationType, aQ as SimpleQueryRunner, $ as TableHooks, _ as TableOptions, aD as TrackedEntity, aB as addDomainEvent, ac as belongsTo, ad as belongsToMany, a5 as col, ai as createColumn, aR as createExecutorFromQueryRunner, aj as createLiteral, aN as createQueryLoggingExecutor, a0 as defineTable, aa as hasMany, ab as hasOne, am as isCaseExpressionNode, ao as isExpressionSelectionNode, al as isFunctionNode, ak as isOperandNode, an as isWindowFunctionNode, aP as rowsToQueryResult } from './select-BPCn6MOH.js';
|
|
3
3
|
|
|
4
|
+
type LiteralValue = LiteralNode['value'];
|
|
5
|
+
type ValueOperandInput = OperandNode | LiteralValue;
|
|
4
6
|
/**
|
|
5
7
|
* Converts a primitive or existing operand into an operand node
|
|
6
8
|
* @param value - Value or operand to normalize
|
|
7
9
|
* @returns OperandNode representing the value
|
|
8
10
|
*/
|
|
9
|
-
declare const valueToOperand: (value:
|
|
11
|
+
declare const valueToOperand: (value: ValueOperandInput) => OperandNode;
|
|
12
|
+
declare const isValueOperandInput: (value: unknown) => value is ValueOperandInput;
|
|
10
13
|
declare const columnOperand: (col: ColumnRef | ColumnNode) => ColumnNode;
|
|
11
14
|
/**
|
|
12
15
|
* Creates an equality expression (left = right)
|
|
@@ -221,6 +224,30 @@ declare const sum: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
|
221
224
|
* @returns Function node with AVG
|
|
222
225
|
*/
|
|
223
226
|
declare const avg: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
227
|
+
/**
|
|
228
|
+
* Creates a MIN function expression
|
|
229
|
+
* @param col - Column to take the minimum of
|
|
230
|
+
* @returns Function node with MIN
|
|
231
|
+
*/
|
|
232
|
+
declare const min: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a MAX function expression
|
|
235
|
+
* @param col - Column to take the maximum of
|
|
236
|
+
* @returns Function node with MAX
|
|
237
|
+
*/
|
|
238
|
+
declare const max: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
239
|
+
type GroupConcatOrderByInput = {
|
|
240
|
+
column: ColumnRef | ColumnNode;
|
|
241
|
+
direction?: OrderDirection;
|
|
242
|
+
};
|
|
243
|
+
type GroupConcatOptions = {
|
|
244
|
+
separator?: ValueOperandInput;
|
|
245
|
+
orderBy?: GroupConcatOrderByInput[];
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Aggregates grouped strings into a single value.
|
|
249
|
+
*/
|
|
250
|
+
declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => FunctionNode;
|
|
224
251
|
|
|
225
252
|
/**
|
|
226
253
|
* Visitor for expression nodes
|
|
@@ -286,6 +313,18 @@ declare const toColumnRef: (col: ColumnRef | ColumnDef) => ColumnRef;
|
|
|
286
313
|
*/
|
|
287
314
|
declare const toTableRef: (table: TableRef | TableDef) => TableRef;
|
|
288
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Build a typed selection map from a TableDef.
|
|
318
|
+
*/
|
|
319
|
+
declare function sel<TTable extends TableDef, K extends keyof TTable['columns'] & string>(table: TTable, ...cols: K[]): Record<K, TTable['columns'][K]>;
|
|
320
|
+
type Ctor<T> = {
|
|
321
|
+
new (...args: any[]): T;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Build a typed selection map from an entity constructor.
|
|
325
|
+
*/
|
|
326
|
+
declare function esel<TEntity, K extends keyof TEntity & string>(entity: Ctor<TEntity>, ...props: K[]): Record<K, ColumnDef>;
|
|
327
|
+
|
|
289
328
|
/**
|
|
290
329
|
* Maintains immutable state for building INSERT queries
|
|
291
330
|
*/
|
|
@@ -1181,12 +1220,22 @@ declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _rel
|
|
|
1181
1220
|
declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, any>>>;
|
|
1182
1221
|
declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
|
|
1183
1222
|
|
|
1223
|
+
/**
|
|
1224
|
+
* Metadata stored on entity instances for ORM internal use
|
|
1225
|
+
* @typeParam TTable - Table definition type
|
|
1226
|
+
*/
|
|
1184
1227
|
interface EntityMeta<TTable extends TableDef> {
|
|
1228
|
+
/** Entity context */
|
|
1185
1229
|
ctx: EntityContext;
|
|
1230
|
+
/** Table definition */
|
|
1186
1231
|
table: TTable;
|
|
1232
|
+
/** Relations that should be loaded lazily */
|
|
1187
1233
|
lazyRelations: (keyof RelationMap<TTable>)[];
|
|
1234
|
+
/** Cache for relation promises */
|
|
1188
1235
|
relationCache: Map<string, Promise<any>>;
|
|
1236
|
+
/** Hydration data for relations */
|
|
1189
1237
|
relationHydration: Map<string, Map<string, any>>;
|
|
1238
|
+
/** Relation wrapper instances */
|
|
1190
1239
|
relationWrappers: Map<string, unknown>;
|
|
1191
1240
|
}
|
|
1192
1241
|
|
|
@@ -1303,4 +1352,4 @@ interface MssqlClientLike {
|
|
|
1303
1352
|
}
|
|
1304
1353
|
declare function createMssqlExecutor(client: MssqlClientLike): DbExecutor;
|
|
1305
1354
|
|
|
1306
|
-
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, type ColumnDiff, ColumnNode, ColumnRef, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, EntityContext, ExecutionContext, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, HasManyCollection, HasManyRelation, HasOneRelation, HydrationContext, HydrationPlan, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, LogicalExpressionNode, ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, NullExpressionNode, OperandNode, type OperandVisitor, OrmSession, type PostgresClientLike, PostgresDialect, RelationMap, type RenderColumnOptions, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, type SqliteClientLike, SqliteDialect, type SynchronizeOptions, TableDef, TableRef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, abs, acos, and, ascii, asin, atan, atan2, avg, between, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, columnOperand, concat, concatWs, cos, cot, count, createEntityFromRow, createEntityProxy, createMssqlExecutor, createMysqlExecutor, createPostgresExecutor, createSqliteExecutor, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, degrees, denseRank, diffSchema, endOfMonth, eq, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getSchemaIntrospector, gt, gte, hydrateRows, inList, instr, introspectSchema, isNotNull, isNull, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, mod, month, neq, notBetween, notExists, notInList, notLike, now, ntile, or, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rpad, rtrim, sign, sin, space, sqrt, substr, sum, synchronizeSchema, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
1355
|
+
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, type ColumnDiff, ColumnNode, ColumnRef, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, EntityContext, ExecutionContext, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, type GroupConcatOptions, HasManyCollection, HasManyRelation, HasOneRelation, HydrationContext, HydrationPlan, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, type LiteralValue, LogicalExpressionNode, ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, NullExpressionNode, OperandNode, type OperandVisitor, OrmSession, type PostgresClientLike, PostgresDialect, RelationMap, type RenderColumnOptions, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, type SqliteClientLike, SqliteDialect, type SynchronizeOptions, TableDef, TableRef, TypeScriptGenerator, UpdateQueryBuilder, type ValueOperandInput, WindowFunctionNode, abs, acos, and, ascii, asin, atan, atan2, avg, between, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, columnOperand, concat, concatWs, cos, cot, count, createEntityFromRow, createEntityProxy, createMssqlExecutor, createMysqlExecutor, createPostgresExecutor, createSqliteExecutor, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, degrees, denseRank, diffSchema, endOfMonth, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getSchemaIntrospector, groupConcat, gt, gte, hydrateRows, inList, instr, introspectSchema, isNotNull, isNull, isValueOperandInput, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, neq, notBetween, notExists, notInList, notLike, now, ntile, or, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rpad, rtrim, sel, sign, sin, space, sqrt, substr, sum, synchronizeSchema, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|