metal-orm 1.0.7 → 1.0.9
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 +133 -121
- package/dist/decorators/index.cjs +2564 -0
- package/dist/decorators/index.cjs.map +1 -0
- package/dist/decorators/index.d.cts +53 -0
- package/dist/decorators/index.d.ts +53 -0
- package/dist/decorators/index.js +2530 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/index.cjs +4227 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +701 -0
- package/dist/index.d.ts +701 -0
- package/dist/index.js +4131 -0
- package/dist/index.js.map +1 -0
- package/dist/select-654m4qy8.d.cts +1522 -0
- package/dist/select-654m4qy8.d.ts +1522 -0
- package/package.json +27 -20
- package/src/codegen/typescript.ts +405 -393
- package/src/core/ast/aggregate-functions.ts +30 -0
- package/src/core/ast/builders.ts +43 -0
- package/src/core/ast/expression-builders.ts +310 -0
- package/src/core/ast/expression-nodes.ts +211 -0
- package/src/core/ast/expression-visitor.ts +99 -0
- package/src/core/ast/expression.ts +5 -0
- package/src/{utils → core/ast}/join-node.ts +20 -20
- package/src/{ast → core/ast}/join.ts +18 -18
- package/src/{ast → core/ast}/query.ts +113 -113
- package/src/core/ast/window-functions.ts +140 -0
- package/src/{dialect → core/dialect}/abstract.ts +94 -94
- package/src/{dialect → core/dialect}/mssql/index.ts +31 -31
- package/src/{dialect → core/dialect}/mysql/index.ts +31 -31
- package/src/{dialect → core/dialect}/postgres/index.ts +45 -45
- package/src/{dialect → core/dialect}/sqlite/index.ts +45 -45
- package/src/{constants → core/sql}/sql-operator-config.ts +39 -39
- package/src/decorators/bootstrap.ts +126 -0
- package/src/decorators/column.ts +78 -0
- package/src/decorators/entity.ts +36 -0
- package/src/decorators/index.ts +4 -0
- package/src/decorators/relations.ts +107 -0
- package/src/global.d.ts +1 -0
- package/src/index.ts +22 -22
- package/src/orm/db-executor.ts +11 -0
- package/src/orm/domain-event-bus.ts +52 -0
- package/src/{runtime → orm}/entity-meta.ts +52 -52
- package/src/orm/entity-metadata.ts +140 -0
- package/src/{runtime → orm}/entity.ts +252 -252
- package/src/{runtime → orm}/execute.ts +36 -36
- package/src/{runtime → orm}/hydration.ts +103 -103
- package/src/orm/identity-map.ts +37 -0
- package/src/{runtime → orm}/lazy-batch.ts +205 -205
- package/src/orm/orm-context.ts +154 -0
- package/src/orm/relation-change-processor.ts +140 -0
- package/src/{runtime → orm}/relations/belongs-to.ts +92 -92
- package/src/{runtime → orm}/relations/has-many.ts +111 -111
- package/src/{runtime → orm}/relations/many-to-many.ts +149 -149
- package/src/orm/runtime-types.ts +39 -0
- package/src/orm/transaction-runner.ts +17 -0
- package/src/orm/unit-of-work.ts +232 -0
- package/src/{builder/operations → query-builder}/column-selector.ts +78 -78
- package/src/{builder → query-builder}/delete-query-state.ts +38 -42
- package/src/{builder → query-builder}/delete.ts +46 -57
- package/src/{builder → query-builder}/hydration-manager.ts +87 -87
- package/src/{builder → query-builder}/hydration-planner.ts +182 -182
- package/src/{builder → query-builder}/insert-query-state.ts +51 -62
- package/src/{builder → query-builder}/insert.ts +48 -59
- package/src/{builder → query-builder}/query-ast-service.ts +208 -226
- package/src/{utils → query-builder}/raw-column-parser.ts +32 -32
- package/src/{builder → query-builder}/relation-conditions.ts +112 -112
- package/src/{builder/operations → query-builder}/relation-manager.ts +82 -82
- package/src/{builder → query-builder}/relation-projection-helper.ts +101 -101
- package/src/{builder → query-builder}/relation-service.ts +284 -284
- package/src/{builder → query-builder}/relation-types.ts +21 -21
- package/src/{builder → query-builder}/relation-utils.ts +12 -12
- package/src/{builder → query-builder}/select-query-builder-deps.ts +112 -94
- package/src/{builder → query-builder}/select-query-state.ts +179 -179
- package/src/{builder → query-builder}/select.ts +78 -69
- package/src/{builder → query-builder}/update-query-state.ts +55 -59
- package/src/{builder → query-builder}/update.ts +50 -61
- package/src/schema/column.ts +25 -25
- package/src/schema/relation.ts +116 -116
- package/src/schema/table.ts +34 -34
- package/src/schema/types.ts +76 -76
- package/.github/workflows/publish-metal-orm.yml +0 -38
- package/ROADMAP.md +0 -125
- package/docs/CHANGES.md +0 -104
- package/docs/advanced-features.md +0 -176
- package/docs/api-reference.md +0 -31
- package/docs/dml-operations.md +0 -156
- package/docs/getting-started.md +0 -171
- package/docs/hydration.md +0 -115
- package/docs/index.md +0 -36
- package/docs/multi-dialect-support.md +0 -59
- package/docs/query-builder.md +0 -135
- package/docs/runtime.md +0 -105
- package/docs/schema-definition.md +0 -112
- package/metadata.json +0 -5
- package/playground/api/playground-api.ts +0 -94
- package/playground/index.html +0 -15
- package/playground/src/App.css +0 -1
- package/playground/src/App.tsx +0 -114
- package/playground/src/components/CodeDisplay.tsx +0 -43
- package/playground/src/components/QueryExecutor.tsx +0 -189
- package/playground/src/components/ResultsTable.tsx +0 -67
- package/playground/src/components/ResultsTabs.tsx +0 -105
- package/playground/src/components/ScenarioList.tsx +0 -56
- package/playground/src/components/logo.svg +0 -45
- package/playground/src/data/scenarios.ts +0 -2
- package/playground/src/main.tsx +0 -9
- package/playground/src/services/PlaygroundApiService.ts +0 -60
- package/postcss.config.cjs +0 -5
- package/sql_sql-ansi-cheatsheet-2025.md +0 -264
- package/src/ast/expression.ts +0 -658
- package/src/builder/operations/cte-manager.ts +0 -34
- package/src/builder/operations/filter-manager.ts +0 -68
- package/src/builder/operations/join-manager.ts +0 -36
- package/src/builder/operations/pagination-manager.ts +0 -36
- package/src/playground/features/playground/api/types.ts +0 -16
- package/src/playground/features/playground/clients/MockClient.ts +0 -17
- package/src/playground/features/playground/clients/SqliteClient.ts +0 -57
- package/src/playground/features/playground/common/IDatabaseClient.ts +0 -10
- package/src/playground/features/playground/data/scenarios/aggregation.ts +0 -36
- package/src/playground/features/playground/data/scenarios/basics.ts +0 -25
- package/src/playground/features/playground/data/scenarios/edge_cases.ts +0 -57
- package/src/playground/features/playground/data/scenarios/filtering.ts +0 -94
- package/src/playground/features/playground/data/scenarios/hydration.ts +0 -27
- package/src/playground/features/playground/data/scenarios/index.ts +0 -29
- package/src/playground/features/playground/data/scenarios/ordering.ts +0 -25
- package/src/playground/features/playground/data/scenarios/pagination.ts +0 -16
- package/src/playground/features/playground/data/scenarios/relationships.ts +0 -75
- package/src/playground/features/playground/data/scenarios/types.ts +0 -70
- package/src/playground/features/playground/data/schema.ts +0 -91
- package/src/playground/features/playground/data/seed.ts +0 -104
- package/src/playground/features/playground/services/QueryExecutionService.ts +0 -121
- package/src/runtime/orm-context.ts +0 -539
- package/tests/belongs-to-many.test.ts +0 -57
- package/tests/between.test.ts +0 -43
- package/tests/case-expression.test.ts +0 -58
- package/tests/complex-exists.test.ts +0 -230
- package/tests/cte.test.ts +0 -118
- package/tests/dml.test.ts +0 -206
- package/tests/exists.test.ts +0 -127
- package/tests/like.test.ts +0 -33
- package/tests/orm-runtime.test.ts +0 -254
- package/tests/postgres.test.ts +0 -30
- package/tests/right-join.test.ts +0 -89
- package/tests/subquery-having.test.ts +0 -193
- package/tests/window-function.test.ts +0 -151
- package/tsconfig.json +0 -30
- package/tsup.config.ts +0 -10
- package/vite.config.ts +0 -22
- package/vitest.config.ts +0 -14
- /package/src/{constants → core/sql}/sql.ts +0 -0
- /package/src/{runtime → orm}/als.ts +0 -0
- /package/src/{utils → query-builder}/relation-alias.ts +0 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, 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, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, H as HydrationPlan, R as RelationMap, o as OrmContext, p as Entity, q as HasManyRelation, r as BelongsToRelation, s as BelongsToManyRelation, t as HasManyCollection, u as BelongsToReference, M as ManyToManyCollection, v as SelectQueryBuilder } from './select-654m4qy8.cjs';
|
|
2
|
+
export { K as CascadeMode, Y as ColumnToTs, y as ColumnType, a8 as DbExecutor, ad as DomainEventHandler, a6 as EntityStatus, ab as HasDomainEvents, Z as InferRow, ae as OrmContextOptions, ac as OrmInterceptor, a7 as QueryResult, aa as RelationChange, P as RelationDef, a9 as RelationKey, A as RelationKinds, G as RelationType, w as TableHooks, a5 as addDomainEvent, V as belongsTo, X as belongsToMany, z as col, _ as createColumn, $ as createLiteral, x as defineTable, Q as hasMany, a2 as isCaseExpressionNode, a4 as isExpressionSelectionNode, a1 as isFunctionNode, a0 as isOperandNode, a3 as isWindowFunctionNode } from './select-654m4qy8.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a primitive or existing operand into an operand node
|
|
6
|
+
* @param value - Value or operand to normalize
|
|
7
|
+
* @returns OperandNode representing the value
|
|
8
|
+
*/
|
|
9
|
+
declare const valueToOperand: (value: unknown) => OperandNode;
|
|
10
|
+
declare const columnOperand: (col: ColumnDef | ColumnNode) => ColumnNode;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an equality expression (left = right)
|
|
13
|
+
* @param left - Left operand
|
|
14
|
+
* @param right - Right operand
|
|
15
|
+
* @returns Binary expression node with equality operator
|
|
16
|
+
*/
|
|
17
|
+
declare const eq: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a not equal expression (left != right)
|
|
20
|
+
*/
|
|
21
|
+
declare const neq: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a greater-than expression (left > right)
|
|
24
|
+
* @param left - Left operand
|
|
25
|
+
* @param right - Right operand
|
|
26
|
+
* @returns Binary expression node with greater-than operator
|
|
27
|
+
*/
|
|
28
|
+
declare const gt: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a greater than or equal expression (left >= right)
|
|
31
|
+
*/
|
|
32
|
+
declare const gte: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a less-than expression (left < right)
|
|
35
|
+
* @param left - Left operand
|
|
36
|
+
* @param right - Right operand
|
|
37
|
+
* @returns Binary expression node with less-than operator
|
|
38
|
+
*/
|
|
39
|
+
declare const lt: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a less than or equal expression (left <= right)
|
|
42
|
+
*/
|
|
43
|
+
declare const lte: (left: OperandNode | ColumnDef, right: OperandNode | ColumnDef | string | number) => BinaryExpressionNode;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a LIKE pattern matching expression
|
|
46
|
+
* @param left - Left operand
|
|
47
|
+
* @param pattern - Pattern to match
|
|
48
|
+
* @param escape - Optional escape character
|
|
49
|
+
* @returns Binary expression node with LIKE operator
|
|
50
|
+
*/
|
|
51
|
+
declare const like: (left: OperandNode | ColumnDef, pattern: string, escape?: string) => BinaryExpressionNode;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a NOT LIKE pattern matching expression
|
|
54
|
+
* @param left - Left operand
|
|
55
|
+
* @param pattern - Pattern to match
|
|
56
|
+
* @param escape - Optional escape character
|
|
57
|
+
* @returns Binary expression node with NOT LIKE operator
|
|
58
|
+
*/
|
|
59
|
+
declare const notLike: (left: OperandNode | ColumnDef, pattern: string, escape?: string) => BinaryExpressionNode;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a logical AND expression
|
|
62
|
+
* @param operands - Expressions to combine with AND
|
|
63
|
+
* @returns Logical expression node with AND operator
|
|
64
|
+
*/
|
|
65
|
+
declare const and: (...operands: ExpressionNode[]) => LogicalExpressionNode;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a logical OR expression
|
|
68
|
+
* @param operands - Expressions to combine with OR
|
|
69
|
+
* @returns Logical expression node with OR operator
|
|
70
|
+
*/
|
|
71
|
+
declare const or: (...operands: ExpressionNode[]) => LogicalExpressionNode;
|
|
72
|
+
/**
|
|
73
|
+
* Creates an IS NULL expression
|
|
74
|
+
* @param left - Operand to check for null
|
|
75
|
+
* @returns Null expression node with IS NULL operator
|
|
76
|
+
*/
|
|
77
|
+
declare const isNull: (left: OperandNode | ColumnDef) => NullExpressionNode;
|
|
78
|
+
/**
|
|
79
|
+
* Creates an IS NOT NULL expression
|
|
80
|
+
* @param left - Operand to check for non-null
|
|
81
|
+
* @returns Null expression node with IS NOT NULL operator
|
|
82
|
+
*/
|
|
83
|
+
declare const isNotNull: (left: OperandNode | ColumnDef) => NullExpressionNode;
|
|
84
|
+
/**
|
|
85
|
+
* Creates an IN expression (value IN list)
|
|
86
|
+
* @param left - Operand to check
|
|
87
|
+
* @param values - Values to check against
|
|
88
|
+
* @returns IN expression node
|
|
89
|
+
*/
|
|
90
|
+
declare const inList: (left: OperandNode | ColumnDef, values: (string | number | LiteralNode)[]) => InExpressionNode;
|
|
91
|
+
/**
|
|
92
|
+
* Creates a NOT IN expression (value NOT IN list)
|
|
93
|
+
* @param left - Operand to check
|
|
94
|
+
* @param values - Values to check against
|
|
95
|
+
* @returns NOT IN expression node
|
|
96
|
+
*/
|
|
97
|
+
declare const notInList: (left: OperandNode | ColumnDef, values: (string | number | LiteralNode)[]) => InExpressionNode;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a BETWEEN expression (value BETWEEN lower AND upper)
|
|
100
|
+
* @param left - Operand to check
|
|
101
|
+
* @param lower - Lower bound
|
|
102
|
+
* @param upper - Upper bound
|
|
103
|
+
* @returns BETWEEN expression node
|
|
104
|
+
*/
|
|
105
|
+
declare const between: (left: OperandNode | ColumnDef, lower: OperandNode | ColumnDef | string | number, upper: OperandNode | ColumnDef | string | number) => BetweenExpressionNode;
|
|
106
|
+
/**
|
|
107
|
+
* Creates a NOT BETWEEN expression (value NOT BETWEEN lower AND upper)
|
|
108
|
+
* @param left - Operand to check
|
|
109
|
+
* @param lower - Lower bound
|
|
110
|
+
* @param upper - Upper bound
|
|
111
|
+
* @returns NOT BETWEEN expression node
|
|
112
|
+
*/
|
|
113
|
+
declare const notBetween: (left: OperandNode | ColumnDef, lower: OperandNode | ColumnDef | string | number, upper: OperandNode | ColumnDef | string | number) => BetweenExpressionNode;
|
|
114
|
+
/**
|
|
115
|
+
* Creates a JSON path expression
|
|
116
|
+
* @param col - Source column
|
|
117
|
+
* @param path - JSON path expression
|
|
118
|
+
* @returns JSON path node
|
|
119
|
+
*/
|
|
120
|
+
declare const jsonPath: (col: ColumnDef | ColumnNode, path: string) => JsonPathNode;
|
|
121
|
+
/**
|
|
122
|
+
* Creates a CASE expression
|
|
123
|
+
* @param conditions - Array of WHEN-THEN conditions
|
|
124
|
+
* @param elseValue - Optional ELSE value
|
|
125
|
+
* @returns CASE expression node
|
|
126
|
+
*/
|
|
127
|
+
declare const caseWhen: (conditions: {
|
|
128
|
+
when: ExpressionNode;
|
|
129
|
+
then: OperandNode | ColumnDef | string | number | boolean | null;
|
|
130
|
+
}[], elseValue?: OperandNode | ColumnDef | string | number | boolean | null) => CaseExpressionNode;
|
|
131
|
+
/**
|
|
132
|
+
* Creates an EXISTS expression
|
|
133
|
+
* @param subquery - Subquery to check for existence
|
|
134
|
+
* @returns EXISTS expression node
|
|
135
|
+
*/
|
|
136
|
+
declare const exists: (subquery: SelectQueryNode) => ExistsExpressionNode;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a NOT EXISTS expression
|
|
139
|
+
* @param subquery - Subquery to check for non-existence
|
|
140
|
+
* @returns NOT EXISTS expression node
|
|
141
|
+
*/
|
|
142
|
+
declare const notExists: (subquery: SelectQueryNode) => ExistsExpressionNode;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Creates a ROW_NUMBER window function
|
|
146
|
+
* @returns Window function node for ROW_NUMBER
|
|
147
|
+
*/
|
|
148
|
+
declare const rowNumber: () => WindowFunctionNode;
|
|
149
|
+
/**
|
|
150
|
+
* Creates a RANK window function
|
|
151
|
+
* @returns Window function node for RANK
|
|
152
|
+
*/
|
|
153
|
+
declare const rank: () => WindowFunctionNode;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a DENSE_RANK window function
|
|
156
|
+
* @returns Window function node for DENSE_RANK
|
|
157
|
+
*/
|
|
158
|
+
declare const denseRank: () => WindowFunctionNode;
|
|
159
|
+
/**
|
|
160
|
+
* Creates an NTILE window function
|
|
161
|
+
* @param n - Number of buckets
|
|
162
|
+
* @returns Window function node for NTILE
|
|
163
|
+
*/
|
|
164
|
+
declare const ntile: (n: number) => WindowFunctionNode;
|
|
165
|
+
/**
|
|
166
|
+
* Creates a LAG window function
|
|
167
|
+
* @param col - Column to lag
|
|
168
|
+
* @param offset - Offset (defaults to 1)
|
|
169
|
+
* @param defaultValue - Default value if no row exists
|
|
170
|
+
* @returns Window function node for LAG
|
|
171
|
+
*/
|
|
172
|
+
declare const lag: (col: ColumnDef | ColumnNode, offset?: number, defaultValue?: any) => WindowFunctionNode;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a LEAD window function
|
|
175
|
+
* @param col - Column to lead
|
|
176
|
+
* @param offset - Offset (defaults to 1)
|
|
177
|
+
* @param defaultValue - Default value if no row exists
|
|
178
|
+
* @returns Window function node for LEAD
|
|
179
|
+
*/
|
|
180
|
+
declare const lead: (col: ColumnDef | ColumnNode, offset?: number, defaultValue?: any) => WindowFunctionNode;
|
|
181
|
+
/**
|
|
182
|
+
* Creates a FIRST_VALUE window function
|
|
183
|
+
* @param col - Column to get first value from
|
|
184
|
+
* @returns Window function node for FIRST_VALUE
|
|
185
|
+
*/
|
|
186
|
+
declare const firstValue: (col: ColumnDef | ColumnNode) => WindowFunctionNode;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a LAST_VALUE window function
|
|
189
|
+
* @param col - Column to get last value from
|
|
190
|
+
* @returns Window function node for LAST_VALUE
|
|
191
|
+
*/
|
|
192
|
+
declare const lastValue: (col: ColumnDef | ColumnNode) => WindowFunctionNode;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a custom window function
|
|
195
|
+
* @param name - Window function name
|
|
196
|
+
* @param args - Function arguments
|
|
197
|
+
* @param partitionBy - Optional PARTITION BY columns
|
|
198
|
+
* @param orderBy - Optional ORDER BY clauses
|
|
199
|
+
* @returns Window function node
|
|
200
|
+
*/
|
|
201
|
+
declare const windowFunction: (name: string, args?: (ColumnDef | ColumnNode | LiteralNode | JsonPathNode)[], partitionBy?: (ColumnDef | ColumnNode)[], orderBy?: {
|
|
202
|
+
column: ColumnDef | ColumnNode;
|
|
203
|
+
direction: OrderDirection;
|
|
204
|
+
}[]) => WindowFunctionNode;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Creates a COUNT function expression
|
|
208
|
+
* @param col - Column to count
|
|
209
|
+
* @returns Function node with COUNT
|
|
210
|
+
*/
|
|
211
|
+
declare const count: (col: ColumnDef | ColumnNode) => FunctionNode;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a SUM function expression
|
|
214
|
+
* @param col - Column to sum
|
|
215
|
+
* @returns Function node with SUM
|
|
216
|
+
*/
|
|
217
|
+
declare const sum: (col: ColumnDef | ColumnNode) => FunctionNode;
|
|
218
|
+
/**
|
|
219
|
+
* Creates an AVG function expression
|
|
220
|
+
* @param col - Column to average
|
|
221
|
+
* @returns Function node with AVG
|
|
222
|
+
*/
|
|
223
|
+
declare const avg: (col: ColumnDef | ColumnNode) => FunctionNode;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Visitor for expression nodes
|
|
227
|
+
*/
|
|
228
|
+
interface ExpressionVisitor<R> {
|
|
229
|
+
visitBinaryExpression(node: BinaryExpressionNode): R;
|
|
230
|
+
visitLogicalExpression(node: LogicalExpressionNode): R;
|
|
231
|
+
visitNullExpression(node: NullExpressionNode): R;
|
|
232
|
+
visitInExpression(node: InExpressionNode): R;
|
|
233
|
+
visitExistsExpression(node: ExistsExpressionNode): R;
|
|
234
|
+
visitBetweenExpression(node: BetweenExpressionNode): R;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Visitor for operand nodes
|
|
238
|
+
*/
|
|
239
|
+
interface OperandVisitor<R> {
|
|
240
|
+
visitColumn(node: ColumnNode): R;
|
|
241
|
+
visitLiteral(node: LiteralNode): R;
|
|
242
|
+
visitFunction(node: FunctionNode): R;
|
|
243
|
+
visitJsonPath(node: JsonPathNode): R;
|
|
244
|
+
visitScalarSubquery(node: ScalarSubqueryNode): R;
|
|
245
|
+
visitCaseExpression(node: CaseExpressionNode): R;
|
|
246
|
+
visitWindowFunction(node: WindowFunctionNode): R;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Dispatches an expression node to the visitor
|
|
250
|
+
* @param node - Expression node to visit
|
|
251
|
+
* @param visitor - Visitor implementation
|
|
252
|
+
*/
|
|
253
|
+
declare const visitExpression: <R>(node: ExpressionNode, visitor: ExpressionVisitor<R>) => R;
|
|
254
|
+
/**
|
|
255
|
+
* Dispatches an operand node to the visitor
|
|
256
|
+
* @param node - Operand node to visit
|
|
257
|
+
* @param visitor - Visitor implementation
|
|
258
|
+
*/
|
|
259
|
+
declare const visitOperand: <R>(node: OperandNode, visitor: OperandVisitor<R>) => R;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Maintains immutable state for building INSERT queries
|
|
263
|
+
*/
|
|
264
|
+
declare class InsertQueryState {
|
|
265
|
+
readonly table: TableDef;
|
|
266
|
+
readonly ast: InsertQueryNode;
|
|
267
|
+
constructor(table: TableDef, ast?: InsertQueryNode);
|
|
268
|
+
private clone;
|
|
269
|
+
withValues(rows: Record<string, unknown>[]): InsertQueryState;
|
|
270
|
+
withReturning(columns: ColumnNode[]): InsertQueryState;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Builder for INSERT queries
|
|
275
|
+
*/
|
|
276
|
+
declare class InsertQueryBuilder<T> {
|
|
277
|
+
private readonly table;
|
|
278
|
+
private readonly state;
|
|
279
|
+
constructor(table: TableDef, state?: InsertQueryState);
|
|
280
|
+
private clone;
|
|
281
|
+
values(rowOrRows: Record<string, unknown> | Record<string, unknown>[]): InsertQueryBuilder<T>;
|
|
282
|
+
returning(...columns: (ColumnDef | ColumnNode)[]): InsertQueryBuilder<T>;
|
|
283
|
+
compile(compiler: InsertCompiler): CompiledQuery;
|
|
284
|
+
toSql(compiler: InsertCompiler): string;
|
|
285
|
+
getAST(): InsertQueryNode;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Immutable state for UPDATE queries
|
|
290
|
+
*/
|
|
291
|
+
declare class UpdateQueryState {
|
|
292
|
+
readonly table: TableDef;
|
|
293
|
+
readonly ast: UpdateQueryNode;
|
|
294
|
+
constructor(table: TableDef, ast?: UpdateQueryNode);
|
|
295
|
+
private clone;
|
|
296
|
+
withSet(values: Record<string, unknown>): UpdateQueryState;
|
|
297
|
+
withWhere(expr: ExpressionNode): UpdateQueryState;
|
|
298
|
+
withReturning(columns: ColumnNode[]): UpdateQueryState;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Builder for UPDATE queries
|
|
303
|
+
*/
|
|
304
|
+
declare class UpdateQueryBuilder<T> {
|
|
305
|
+
private readonly table;
|
|
306
|
+
private readonly state;
|
|
307
|
+
constructor(table: TableDef, state?: UpdateQueryState);
|
|
308
|
+
private clone;
|
|
309
|
+
set(values: Record<string, unknown>): UpdateQueryBuilder<T>;
|
|
310
|
+
where(expr: ExpressionNode): UpdateQueryBuilder<T>;
|
|
311
|
+
returning(...columns: (ColumnDef | ColumnNode)[]): UpdateQueryBuilder<T>;
|
|
312
|
+
compile(compiler: UpdateCompiler): CompiledQuery;
|
|
313
|
+
toSql(compiler: UpdateCompiler): string;
|
|
314
|
+
getAST(): UpdateQueryNode;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Maintains immutable state for DELETE queries
|
|
319
|
+
*/
|
|
320
|
+
declare class DeleteQueryState {
|
|
321
|
+
readonly table: TableDef;
|
|
322
|
+
readonly ast: DeleteQueryNode;
|
|
323
|
+
constructor(table: TableDef, ast?: DeleteQueryNode);
|
|
324
|
+
private clone;
|
|
325
|
+
withWhere(expr: ExpressionNode): DeleteQueryState;
|
|
326
|
+
withReturning(columns: ColumnNode[]): DeleteQueryState;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Builder for DELETE queries
|
|
331
|
+
*/
|
|
332
|
+
declare class DeleteQueryBuilder<T> {
|
|
333
|
+
private readonly table;
|
|
334
|
+
private readonly state;
|
|
335
|
+
constructor(table: TableDef, state?: DeleteQueryState);
|
|
336
|
+
private clone;
|
|
337
|
+
where(expr: ExpressionNode): DeleteQueryBuilder<T>;
|
|
338
|
+
returning(...columns: (ColumnDef | ColumnNode)[]): DeleteQueryBuilder<T>;
|
|
339
|
+
compile(compiler: DeleteCompiler): CompiledQuery;
|
|
340
|
+
toSql(compiler: DeleteCompiler): string;
|
|
341
|
+
getAST(): DeleteQueryNode;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* MySQL dialect implementation
|
|
346
|
+
*/
|
|
347
|
+
declare class MySqlDialect extends Dialect {
|
|
348
|
+
/**
|
|
349
|
+
* Creates a new MySqlDialect instance
|
|
350
|
+
*/
|
|
351
|
+
constructor();
|
|
352
|
+
/**
|
|
353
|
+
* Quotes an identifier using MySQL backtick syntax
|
|
354
|
+
* @param id - Identifier to quote
|
|
355
|
+
* @returns Quoted identifier
|
|
356
|
+
*/
|
|
357
|
+
quoteIdentifier(id: string): string;
|
|
358
|
+
/**
|
|
359
|
+
* Compiles JSON path expression using MySQL syntax
|
|
360
|
+
* @param node - JSON path node
|
|
361
|
+
* @returns MySQL JSON path expression
|
|
362
|
+
*/
|
|
363
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
364
|
+
/**
|
|
365
|
+
* Compiles SELECT query AST to MySQL SQL
|
|
366
|
+
* @param ast - Query AST
|
|
367
|
+
* @param ctx - Compiler context
|
|
368
|
+
* @returns MySQL SQL string
|
|
369
|
+
*/
|
|
370
|
+
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
371
|
+
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
372
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
373
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Microsoft SQL Server dialect implementation
|
|
378
|
+
*/
|
|
379
|
+
declare class SqlServerDialect extends Dialect {
|
|
380
|
+
/**
|
|
381
|
+
* Creates a new SqlServerDialect instance
|
|
382
|
+
*/
|
|
383
|
+
constructor();
|
|
384
|
+
/**
|
|
385
|
+
* Quotes an identifier using SQL Server bracket syntax
|
|
386
|
+
* @param id - Identifier to quote
|
|
387
|
+
* @returns Quoted identifier
|
|
388
|
+
*/
|
|
389
|
+
quoteIdentifier(id: string): string;
|
|
390
|
+
/**
|
|
391
|
+
* Compiles JSON path expression using SQL Server syntax
|
|
392
|
+
* @param node - JSON path node
|
|
393
|
+
* @returns SQL Server JSON path expression
|
|
394
|
+
*/
|
|
395
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
396
|
+
/**
|
|
397
|
+
* Formats parameter placeholders using SQL Server named parameter syntax
|
|
398
|
+
* @param index - Parameter index
|
|
399
|
+
* @returns Named parameter placeholder
|
|
400
|
+
*/
|
|
401
|
+
protected formatPlaceholder(index: number): string;
|
|
402
|
+
/**
|
|
403
|
+
* Compiles SELECT query AST to SQL Server SQL
|
|
404
|
+
* @param ast - Query AST
|
|
405
|
+
* @param ctx - Compiler context
|
|
406
|
+
* @returns SQL Server SQL string
|
|
407
|
+
*/
|
|
408
|
+
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
409
|
+
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
410
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
411
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* SQLite dialect implementation
|
|
416
|
+
*/
|
|
417
|
+
declare class SqliteDialect extends Dialect {
|
|
418
|
+
/**
|
|
419
|
+
* Creates a new SqliteDialect instance
|
|
420
|
+
*/
|
|
421
|
+
constructor();
|
|
422
|
+
/**
|
|
423
|
+
* Quotes an identifier using SQLite double-quote syntax
|
|
424
|
+
* @param id - Identifier to quote
|
|
425
|
+
* @returns Quoted identifier
|
|
426
|
+
*/
|
|
427
|
+
quoteIdentifier(id: string): string;
|
|
428
|
+
/**
|
|
429
|
+
* Compiles JSON path expression using SQLite syntax
|
|
430
|
+
* @param node - JSON path node
|
|
431
|
+
* @returns SQLite JSON path expression
|
|
432
|
+
*/
|
|
433
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
434
|
+
/**
|
|
435
|
+
* Compiles SELECT query AST to SQLite SQL
|
|
436
|
+
* @param ast - Query AST
|
|
437
|
+
* @param ctx - Compiler context
|
|
438
|
+
* @returns SQLite SQL string
|
|
439
|
+
*/
|
|
440
|
+
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
441
|
+
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
442
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
443
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
444
|
+
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Browser-compatible implementation of AsyncLocalStorage
|
|
449
|
+
* Provides a simple in-memory store for browser environments
|
|
450
|
+
* @typeParam T - Type of the stored data
|
|
451
|
+
*/
|
|
452
|
+
declare class AsyncLocalStorage<T> {
|
|
453
|
+
private store;
|
|
454
|
+
/**
|
|
455
|
+
* Executes a callback with the specified store value
|
|
456
|
+
* @param store - Value to store during callback execution
|
|
457
|
+
* @param callback - Function to execute with the store value
|
|
458
|
+
* @returns Result of the callback function
|
|
459
|
+
*/
|
|
460
|
+
run<R>(store: T, callback: () => R): R;
|
|
461
|
+
/**
|
|
462
|
+
* Gets the currently stored value
|
|
463
|
+
* @returns Current store value or undefined if none exists
|
|
464
|
+
*/
|
|
465
|
+
getStore(): T | undefined;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Hydrates query results according to a hydration plan
|
|
470
|
+
* @param rows - Raw database rows
|
|
471
|
+
* @param plan - Hydration plan
|
|
472
|
+
* @returns Hydrated result objects with nested relations
|
|
473
|
+
*/
|
|
474
|
+
declare const hydrateRows: (rows: Record<string, any>[], plan?: HydrationPlan) => Record<string, any>[];
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Generates TypeScript code from query AST nodes
|
|
478
|
+
*/
|
|
479
|
+
declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandVisitor<string> {
|
|
480
|
+
/**
|
|
481
|
+
* Generates TypeScript code from a query AST
|
|
482
|
+
* @param ast - Query AST to generate code from
|
|
483
|
+
* @returns Generated TypeScript code
|
|
484
|
+
*/
|
|
485
|
+
generate(ast: SelectQueryNode): string;
|
|
486
|
+
/**
|
|
487
|
+
* Builds TypeScript method chain lines from query AST
|
|
488
|
+
* @param ast - Query AST
|
|
489
|
+
* @returns Array of TypeScript method chain lines
|
|
490
|
+
*/
|
|
491
|
+
private buildSelectLines;
|
|
492
|
+
/**
|
|
493
|
+
* Prints an expression node to TypeScript code
|
|
494
|
+
* @param expr - Expression node to print
|
|
495
|
+
* @returns TypeScript code representation
|
|
496
|
+
*/
|
|
497
|
+
private printExpression;
|
|
498
|
+
/**
|
|
499
|
+
* Prints an operand node to TypeScript code
|
|
500
|
+
* @param node - Operand node to print
|
|
501
|
+
* @returns TypeScript code representation
|
|
502
|
+
*/
|
|
503
|
+
private printOperand;
|
|
504
|
+
visitBinaryExpression(binary: BinaryExpressionNode): string;
|
|
505
|
+
visitLogicalExpression(logical: LogicalExpressionNode): string;
|
|
506
|
+
visitNullExpression(nullExpr: NullExpressionNode): string;
|
|
507
|
+
visitInExpression(inExpr: InExpressionNode): string;
|
|
508
|
+
visitExistsExpression(existsExpr: ExistsExpressionNode): string;
|
|
509
|
+
visitBetweenExpression(betweenExpr: BetweenExpressionNode): string;
|
|
510
|
+
visitColumn(node: ColumnNode): string;
|
|
511
|
+
visitLiteral(node: LiteralNode): string;
|
|
512
|
+
visitFunction(node: FunctionNode): string;
|
|
513
|
+
visitJsonPath(node: JsonPathNode): string;
|
|
514
|
+
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
515
|
+
visitCaseExpression(node: CaseExpressionNode): string;
|
|
516
|
+
visitWindowFunction(node: WindowFunctionNode): string;
|
|
517
|
+
/**
|
|
518
|
+
* Prints a binary expression to TypeScript code
|
|
519
|
+
* @param binary - Binary expression node
|
|
520
|
+
* @returns TypeScript code representation
|
|
521
|
+
*/
|
|
522
|
+
private printBinaryExpression;
|
|
523
|
+
/**
|
|
524
|
+
* Prints a logical expression to TypeScript code
|
|
525
|
+
* @param logical - Logical expression node
|
|
526
|
+
* @returns TypeScript code representation
|
|
527
|
+
*/
|
|
528
|
+
private printLogicalExpression;
|
|
529
|
+
/**
|
|
530
|
+
* Prints an IN expression to TypeScript code
|
|
531
|
+
* @param inExpr - IN expression node
|
|
532
|
+
* @returns TypeScript code representation
|
|
533
|
+
*/
|
|
534
|
+
private printInExpression;
|
|
535
|
+
/**
|
|
536
|
+
* Prints a null expression to TypeScript code
|
|
537
|
+
* @param nullExpr - Null expression node
|
|
538
|
+
* @returns TypeScript code representation
|
|
539
|
+
*/
|
|
540
|
+
private printNullExpression;
|
|
541
|
+
/**
|
|
542
|
+
* Prints a BETWEEN expression to TypeScript code
|
|
543
|
+
* @param betweenExpr - BETWEEN expression node
|
|
544
|
+
* @returns TypeScript code representation
|
|
545
|
+
*/
|
|
546
|
+
private printBetweenExpression;
|
|
547
|
+
/**
|
|
548
|
+
* Prints an EXISTS expression to TypeScript code
|
|
549
|
+
* @param existsExpr - EXISTS expression node
|
|
550
|
+
* @returns TypeScript code representation
|
|
551
|
+
*/
|
|
552
|
+
private printExistsExpression;
|
|
553
|
+
/**
|
|
554
|
+
* Prints a column operand to TypeScript code
|
|
555
|
+
* @param column - Column node
|
|
556
|
+
* @returns TypeScript code representation
|
|
557
|
+
*/
|
|
558
|
+
private printColumnOperand;
|
|
559
|
+
/**
|
|
560
|
+
* Prints a literal operand to TypeScript code
|
|
561
|
+
* @param literal - Literal node
|
|
562
|
+
* @returns TypeScript code representation
|
|
563
|
+
*/
|
|
564
|
+
private printLiteralOperand;
|
|
565
|
+
/**
|
|
566
|
+
* Prints a function operand to TypeScript code
|
|
567
|
+
* @param fn - Function node
|
|
568
|
+
* @returns TypeScript code representation
|
|
569
|
+
*/
|
|
570
|
+
private printFunctionOperand;
|
|
571
|
+
/**
|
|
572
|
+
* Prints a JSON path operand to TypeScript code
|
|
573
|
+
* @param json - JSON path node
|
|
574
|
+
* @returns TypeScript code representation
|
|
575
|
+
*/
|
|
576
|
+
private printJsonPathOperand;
|
|
577
|
+
/**
|
|
578
|
+
* Prints a scalar subquery operand to TypeScript code
|
|
579
|
+
* @param node - Scalar subquery node
|
|
580
|
+
* @returns TypeScript code representation
|
|
581
|
+
*/
|
|
582
|
+
private printScalarSubqueryOperand;
|
|
583
|
+
/**
|
|
584
|
+
* Prints a CASE expression operand to TypeScript code
|
|
585
|
+
* @param node - CASE expression node
|
|
586
|
+
* @returns TypeScript code representation
|
|
587
|
+
*/
|
|
588
|
+
private printCaseExpressionOperand;
|
|
589
|
+
/**
|
|
590
|
+
* Prints a window function operand to TypeScript code
|
|
591
|
+
* @param node - Window function node
|
|
592
|
+
* @returns TypeScript code representation
|
|
593
|
+
*/
|
|
594
|
+
private printWindowFunctionOperand;
|
|
595
|
+
/**
|
|
596
|
+
* Converts method chain lines to inline format
|
|
597
|
+
* @param lines - Method chain lines
|
|
598
|
+
* @returns Inline method chain string
|
|
599
|
+
*/
|
|
600
|
+
private inlineChain;
|
|
601
|
+
/**
|
|
602
|
+
* Maps SQL operators to TypeScript function names
|
|
603
|
+
* @param op - SQL operator
|
|
604
|
+
* @returns TypeScript function name
|
|
605
|
+
*/
|
|
606
|
+
private mapOp;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: OrmContext, table: TTable, row: Record<string, any>, lazyRelations?: TLazy[]) => Entity<TTable>;
|
|
610
|
+
declare const createEntityFromRow: <TTable extends TableDef>(ctx: OrmContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) => Entity<TTable>;
|
|
611
|
+
|
|
612
|
+
type Rows$3 = Record<string, any>[];
|
|
613
|
+
declare const loadHasManyRelation: (ctx: OrmContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
|
|
614
|
+
declare const loadBelongsToRelation: (ctx: OrmContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, any>>>;
|
|
615
|
+
declare const loadBelongsToManyRelation: (ctx: OrmContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
|
|
616
|
+
|
|
617
|
+
interface EntityMeta<TTable extends TableDef> {
|
|
618
|
+
ctx: OrmContext;
|
|
619
|
+
table: TTable;
|
|
620
|
+
lazyRelations: (keyof RelationMap<TTable>)[];
|
|
621
|
+
relationCache: Map<string, Promise<any>>;
|
|
622
|
+
relationHydration: Map<string, Map<string, any>>;
|
|
623
|
+
relationWrappers: Map<string, unknown>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
type Rows$2 = Record<string, any>[];
|
|
627
|
+
declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChild> {
|
|
628
|
+
private readonly ctx;
|
|
629
|
+
private readonly meta;
|
|
630
|
+
private readonly root;
|
|
631
|
+
private readonly relationName;
|
|
632
|
+
private readonly relation;
|
|
633
|
+
private readonly rootTable;
|
|
634
|
+
private readonly loader;
|
|
635
|
+
private readonly createEntity;
|
|
636
|
+
private readonly localKey;
|
|
637
|
+
private loaded;
|
|
638
|
+
private items;
|
|
639
|
+
private readonly added;
|
|
640
|
+
private readonly removed;
|
|
641
|
+
constructor(ctx: OrmContext, meta: EntityMeta<any>, root: any, relationName: string, relation: HasManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$2>>, createEntity: (row: Record<string, any>) => TChild, localKey: string);
|
|
642
|
+
load(): Promise<TChild[]>;
|
|
643
|
+
getItems(): TChild[];
|
|
644
|
+
add(data: Partial<TChild>): TChild;
|
|
645
|
+
attach(entity: TChild): void;
|
|
646
|
+
remove(entity: TChild): void;
|
|
647
|
+
clear(): void;
|
|
648
|
+
private get relationKey();
|
|
649
|
+
private hydrateFromCache;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
type Rows$1 = Record<string, any>;
|
|
653
|
+
declare class DefaultBelongsToReference<TParent> implements BelongsToReference<TParent> {
|
|
654
|
+
private readonly ctx;
|
|
655
|
+
private readonly meta;
|
|
656
|
+
private readonly root;
|
|
657
|
+
private readonly relationName;
|
|
658
|
+
private readonly relation;
|
|
659
|
+
private readonly rootTable;
|
|
660
|
+
private readonly loader;
|
|
661
|
+
private readonly createEntity;
|
|
662
|
+
private readonly targetKey;
|
|
663
|
+
private loaded;
|
|
664
|
+
private current;
|
|
665
|
+
constructor(ctx: OrmContext, meta: EntityMeta<any>, root: any, relationName: string, relation: BelongsToRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$1>>, createEntity: (row: Record<string, any>) => TParent, targetKey: string);
|
|
666
|
+
load(): Promise<TParent | null>;
|
|
667
|
+
get(): TParent | null;
|
|
668
|
+
set(data: Partial<TParent> | TParent | null): TParent | null;
|
|
669
|
+
private get relationKey();
|
|
670
|
+
private populateFromHydrationCache;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
type Rows = Record<string, any>[];
|
|
674
|
+
declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollection<TTarget> {
|
|
675
|
+
private readonly ctx;
|
|
676
|
+
private readonly meta;
|
|
677
|
+
private readonly root;
|
|
678
|
+
private readonly relationName;
|
|
679
|
+
private readonly relation;
|
|
680
|
+
private readonly rootTable;
|
|
681
|
+
private readonly loader;
|
|
682
|
+
private readonly createEntity;
|
|
683
|
+
private readonly localKey;
|
|
684
|
+
private loaded;
|
|
685
|
+
private items;
|
|
686
|
+
constructor(ctx: OrmContext, meta: EntityMeta<any>, root: any, relationName: string, relation: BelongsToManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows>>, createEntity: (row: Record<string, any>) => TTarget, localKey: string);
|
|
687
|
+
load(): Promise<TTarget[]>;
|
|
688
|
+
getItems(): TTarget[];
|
|
689
|
+
attach(target: TTarget | number | string): void;
|
|
690
|
+
detach(target: TTarget | number | string): void;
|
|
691
|
+
syncByIds(ids: (number | string)[]): Promise<void>;
|
|
692
|
+
private ensureEntity;
|
|
693
|
+
private extractId;
|
|
694
|
+
private get relationKey();
|
|
695
|
+
private get targetKey();
|
|
696
|
+
private hydrateFromCache;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;
|
|
700
|
+
|
|
701
|
+
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, ColumnNode, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, Entity, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, FunctionNode, HasManyCollection, HasManyRelation, InExpressionNode, InsertQueryBuilder, JsonPathNode, LiteralNode, LogicalExpressionNode, ManyToManyCollection, MySqlDialect, NullExpressionNode, OperandNode, type OperandVisitor, OrmContext, RelationMap, ScalarSubqueryNode, SelectQueryBuilder, SqlServerDialect, SqliteDialect, TableDef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, and, avg, between, caseWhen, columnOperand, count, createEntityFromRow, createEntityProxy, denseRank, eq, executeHydrated, exists, firstValue, gt, gte, hydrateRows, inList, isNotNull, isNull, jsonPath, lag, lastValue, lead, like, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, lt, lte, neq, notBetween, notExists, notInList, notLike, ntile, or, rank, rowNumber, sum, valueToOperand, visitExpression, visitOperand, windowFunction };
|