metal-orm 1.0.62 → 1.0.64

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/dist/index.d.ts CHANGED
@@ -883,6 +883,11 @@ type ExpressionNode = BinaryExpressionNode | LogicalExpressionNode | NullExpress
883
883
 
884
884
  type LiteralValue = LiteralNode['value'];
885
885
  type ValueOperandInput = OperandNode | LiteralValue;
886
+ type TypedLike<T> = {
887
+ tsType?: T;
888
+ } | {
889
+ __tsType: T;
890
+ };
886
891
  /**
887
892
  * Converts a primitive or existing operand into an operand node
888
893
  * @param value - Value or operand to normalize
@@ -914,272 +919,481 @@ declare const aliasRef: (name: string) => AliasRefNode;
914
919
  */
915
920
  declare const correlateBy: (table: string, column: string) => ColumnNode;
916
921
  /**
917
- * Creates an equality expression (left = right)
918
- * @param left - Left operand
919
- * @param right - Right operand
920
- * @returns Binary expression node with equality operator
922
+ * Creates an equality expression (`left = right`).
923
+ *
924
+ * Supports type safety when used with `ColumnDef` objects containing strict type information.
925
+ *
926
+ * @param left - The left operand (column or value).
927
+ * @param right - The right operand (column or value).
928
+ * @returns A `BinaryExpressionNode` representing the equality check.
929
+ *
930
+ * @example
931
+ * // Basic usage
932
+ * eq(users.id, 1);
933
+ *
934
+ * // With strict typing (typescript will error if types mismatch)
935
+ * eq(users.firstName, 'Ada');
921
936
  */
922
- declare const eq: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean) => BinaryExpressionNode;
937
+ declare function eq<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
938
+ declare function eq(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean): BinaryExpressionNode;
923
939
  /**
924
- * Creates a not equal expression (left != right)
940
+ * Creates a not equal expression (`left != right`).
941
+ *
942
+ * @param left - The left operand (column or value).
943
+ * @param right - The right operand (column or value).
944
+ * @returns A `BinaryExpressionNode` representing the inequality check.
945
+ *
946
+ * @example
947
+ * neq(users.status, 'inactive');
925
948
  */
926
- declare const neq: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean) => BinaryExpressionNode;
949
+ declare function neq<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
950
+ declare function neq(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean): BinaryExpressionNode;
927
951
  /**
928
- * Creates a greater-than expression (left > right)
929
- * @param left - Left operand
930
- * @param right - Right operand
931
- * @returns Binary expression node with greater-than operator
952
+ * Creates a greater-than expression (`left > right`).
953
+ *
954
+ * @param left - The left operand.
955
+ * @param right - The right operand.
956
+ * @returns A `BinaryExpressionNode`.
957
+ *
958
+ * @example
959
+ * gt(users.age, 18);
932
960
  */
933
- declare const gt: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
961
+ declare function gt<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
962
+ declare function gt(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
934
963
  /**
935
- * Creates a greater than or equal expression (left >= right)
964
+ * Creates a greater-than-or-equal expression (`left >= right`).
965
+ *
966
+ * @param left - The left operand.
967
+ * @param right - The right operand.
968
+ * @returns A `BinaryExpressionNode`.
969
+ *
970
+ * @example
971
+ * gte(users.score, 100);
936
972
  */
937
- declare const gte: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
973
+ declare function gte<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
974
+ declare function gte(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
938
975
  /**
939
- * Creates a less-than expression (left < right)
940
- * @param left - Left operand
941
- * @param right - Right operand
942
- * @returns Binary expression node with less-than operator
976
+ * Creates a less-than expression (`left < right`).
977
+ *
978
+ * @param left - The left operand.
979
+ * @param right - The right operand.
980
+ * @returns A `BinaryExpressionNode`.
981
+ *
982
+ * @example
983
+ * lt(inventory.stock, 5);
943
984
  */
944
- declare const lt: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
985
+ declare function lt<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
986
+ declare function lt(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
945
987
  /**
946
- * Creates a less than or equal expression (left <= right)
988
+ * Creates a less-than-or-equal expression (`left <= right`).
989
+ *
990
+ * @param left - The left operand.
991
+ * @param right - The right operand.
992
+ * @returns A `BinaryExpressionNode`.
993
+ *
994
+ * @example
995
+ * lte(products.price, 50.00);
947
996
  */
948
- declare const lte: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
997
+ declare function lte<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
998
+ declare function lte(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
949
999
  /**
950
- * Creates a LIKE pattern matching expression
951
- * @param left - Left operand
952
- * @param pattern - Pattern to match
953
- * @param escape - Optional escape character
954
- * @returns Binary expression node with LIKE operator
1000
+ * Creates a `LIKE` pattern matching expression.
1001
+ *
1002
+ * @param left - The column or expression to check.
1003
+ * @param pattern - The pattern string (e.g., 'A%').
1004
+ * @param escape - Optional escape character.
1005
+ * @returns A `BinaryExpressionNode`.
1006
+ *
1007
+ * @example
1008
+ * like(users.email, '%@gmail.com');
955
1009
  */
956
1010
  declare const like: (left: OperandNode | ColumnRef, pattern: string, escape?: string) => BinaryExpressionNode;
957
1011
  /**
958
- * Creates a NOT LIKE pattern matching expression
959
- * @param left - Left operand
960
- * @param pattern - Pattern to match
961
- * @param escape - Optional escape character
962
- * @returns Binary expression node with NOT LIKE operator
1012
+ * Creates a `NOT LIKE` pattern matching expression.
1013
+ *
1014
+ * @param left - The column or expression to check.
1015
+ * @param pattern - The pattern string.
1016
+ * @param escape - Optional escape character.
1017
+ * @returns A `BinaryExpressionNode`.
1018
+ *
1019
+ * @example
1020
+ * notLike(users.email, 'test%');
963
1021
  */
964
1022
  declare const notLike: (left: OperandNode | ColumnRef, pattern: string, escape?: string) => BinaryExpressionNode;
965
1023
  /**
966
- * Creates a logical AND expression
967
- * @param operands - Expressions to combine with AND
968
- * @returns Logical expression node with AND operator
1024
+ * Creates a logical AND expression to combine multiple conditions.
1025
+ *
1026
+ * @param operands - One or more conditions to combine.
1027
+ * @returns A `LogicalExpressionNode`.
1028
+ *
1029
+ * @example
1030
+ * and(
1031
+ * eq(users.isActive, true),
1032
+ * gt(users.age, 18)
1033
+ * );
969
1034
  */
970
1035
  declare const and: (...operands: ExpressionNode[]) => LogicalExpressionNode;
971
1036
  /**
972
- * Creates a logical OR expression
973
- * @param operands - Expressions to combine with OR
974
- * @returns Logical expression node with OR operator
1037
+ * Creates a logical OR expression to combine multiple conditions.
1038
+ *
1039
+ * @param operands - One or more conditions to combine.
1040
+ * @returns A `LogicalExpressionNode`.
1041
+ *
1042
+ * @example
1043
+ * or(
1044
+ * eq(users.role, 'admin'),
1045
+ * eq(users.role, 'moderator')
1046
+ * );
975
1047
  */
976
1048
  declare const or: (...operands: ExpressionNode[]) => LogicalExpressionNode;
977
1049
  /**
978
- * Creates an IS NULL expression
979
- * @param left - Operand to check for null
980
- * @returns Null expression node with IS NULL operator
1050
+ * Creates an IS NULL check (`left IS NULL`).
1051
+ *
1052
+ * @param left - The operand to check.
1053
+ * @returns A `NullExpressionNode`.
1054
+ *
1055
+ * @example
1056
+ * isNull(users.deletedAt);
981
1057
  */
982
1058
  declare const isNull: (left: OperandNode | ColumnRef) => NullExpressionNode;
983
1059
  /**
984
- * Creates an IS NOT NULL expression
985
- * @param left - Operand to check for non-null
986
- * @returns Null expression node with IS NOT NULL operator
1060
+ * Creates an IS NOT NULL check (`left IS NOT NULL`).
1061
+ *
1062
+ * @param left - The operand to check.
1063
+ * @returns A `NullExpressionNode`.
1064
+ *
1065
+ * @example
1066
+ * isNotNull(users.email);
987
1067
  */
988
1068
  declare const isNotNull: (left: OperandNode | ColumnRef) => NullExpressionNode;
989
1069
  /**
990
- * Creates an IN expression (value IN list)
991
- * @param left - Operand to check
992
- * @param values - Values to check against
993
- * @returns IN expression node
1070
+ * Creates an IN list check (`left IN (v1, v2, ...)`).
1071
+ *
1072
+ * @param left - The operand to check.
1073
+ * @param values - An array of values to check against.
1074
+ * @returns An `InExpressionNode`.
1075
+ *
1076
+ * @example
1077
+ * inList(users.status, ['active', 'pending']);
994
1078
  */
995
1079
  declare const inList: (left: OperandNode | ColumnRef, values: (string | number | LiteralNode)[]) => InExpressionNode;
996
1080
  /**
997
- * Creates a NOT IN expression (value NOT IN list)
998
- * @param left - Operand to check
999
- * @param values - Values to check against
1000
- * @returns NOT IN expression node
1081
+ * Creates a NOT IN list check (`left NOT IN (v1, v2, ...)`).
1082
+ *
1083
+ * @param left - The operand to check.
1084
+ * @param values - An array of values to check against.
1085
+ * @returns An `InExpressionNode`.
1086
+ *
1087
+ * @example
1088
+ * notInList(users.id, [1, 2, 3]);
1001
1089
  */
1002
1090
  declare const notInList: (left: OperandNode | ColumnRef, values: (string | number | LiteralNode)[]) => InExpressionNode;
1091
+ /**
1092
+ * Creates an IN subquery check (`left IN (SELECT ...)`).
1093
+ *
1094
+ * @param left - The operand to check.
1095
+ * @param subquery - The subquery to run.
1096
+ * @returns An `InExpressionNode`.
1097
+ *
1098
+ * @example
1099
+ * inSubquery(
1100
+ * posts.authorId,
1101
+ * selectFromEntity(User).select({ id: users.id }).where(eq(users.isActive, true))
1102
+ * );
1103
+ */
1003
1104
  declare const inSubquery: (left: OperandNode | ColumnRef, subquery: SelectQueryInput) => InExpressionNode;
1105
+ /**
1106
+ * Creates a NOT IN subquery check (`left NOT IN (SELECT ...)`).
1107
+ *
1108
+ * @param left - The operand to check.
1109
+ * @param subquery - The subquery to run.
1110
+ * @returns An `InExpressionNode`.
1111
+ *
1112
+ * @example
1113
+ * notInSubquery(
1114
+ * users.id,
1115
+ * selectFromEntity(Blacklist).select({ userId: blacklist.userId })
1116
+ * );
1117
+ */
1004
1118
  declare const notInSubquery: (left: OperandNode | ColumnRef, subquery: SelectQueryInput) => InExpressionNode;
1005
1119
  /**
1006
- * Creates a BETWEEN expression (value BETWEEN lower AND upper)
1007
- * @param left - Operand to check
1008
- * @param lower - Lower bound
1009
- * @param upper - Upper bound
1010
- * @returns BETWEEN expression node
1120
+ * Creates a BETWEEN check (`left BETWEEN lower AND upper`).
1121
+ *
1122
+ * @param left - The operand to check.
1123
+ * @param lower - The lower bound (inclusive).
1124
+ * @param upper - The upper bound (inclusive).
1125
+ * @returns A `BetweenExpressionNode`.
1126
+ *
1127
+ * @example
1128
+ * between(products.price, 10, 100);
1011
1129
  */
1012
1130
  declare const between: (left: OperandNode | ColumnRef, lower: OperandNode | ColumnRef | string | number, upper: OperandNode | ColumnRef | string | number) => BetweenExpressionNode;
1013
1131
  /**
1014
- * Creates a NOT BETWEEN expression (value NOT BETWEEN lower AND upper)
1015
- * @param left - Operand to check
1016
- * @param lower - Lower bound
1017
- * @param upper - Upper bound
1018
- * @returns NOT BETWEEN expression node
1132
+ * Creates a NOT BETWEEN check (`left NOT BETWEEN lower AND upper`).
1133
+ *
1134
+ * @param left - The operand to check.
1135
+ * @param lower - The lower bound (inclusive).
1136
+ * @param upper - The upper bound (inclusive).
1137
+ * @returns A `BetweenExpressionNode`.
1138
+ *
1139
+ * @example
1140
+ * notBetween(users.age, 20, 30);
1019
1141
  */
1020
1142
  declare const notBetween: (left: OperandNode | ColumnRef, lower: OperandNode | ColumnRef | string | number, upper: OperandNode | ColumnRef | string | number) => BetweenExpressionNode;
1143
+ /**
1144
+ * Creates an addition expression (`left + right`).
1145
+ *
1146
+ * @param left - The left operand.
1147
+ * @param right - The right operand.
1148
+ * @returns An `ArithmeticExpressionNode`.
1149
+ */
1021
1150
  declare const add: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1151
+ /**
1152
+ * Creates a subtraction expression (`left - right`).
1153
+ *
1154
+ * @param left - The left operand.
1155
+ * @param right - The right operand.
1156
+ * @returns An `ArithmeticExpressionNode`.
1157
+ */
1022
1158
  declare const sub: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1159
+ /**
1160
+ * Creates a multiplication expression (`left * right`).
1161
+ *
1162
+ * @param left - The left operand.
1163
+ * @param right - The right operand.
1164
+ * @returns An `ArithmeticExpressionNode`.
1165
+ */
1023
1166
  declare const mul: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1167
+ /**
1168
+ * Creates a division expression (`left / right`).
1169
+ *
1170
+ * @param left - The left operand.
1171
+ * @param right - The right operand.
1172
+ * @returns An `ArithmeticExpressionNode`.
1173
+ */
1024
1174
  declare const div: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1025
1175
  /**
1026
- * Creates a bitwise AND expression (left & right)
1176
+ * Creates a bitwise AND expression (`left & right`).
1177
+ *
1178
+ * @param left - The left operand.
1179
+ * @param right - The right operand.
1180
+ * @returns A `BitwiseExpressionNode`.
1027
1181
  */
1028
1182
  declare const bitAnd: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1029
1183
  /**
1030
- * Creates a bitwise OR expression (left | right)
1184
+ * Creates a bitwise OR expression (`left | right`).
1185
+ *
1186
+ * @param left - The left operand.
1187
+ * @param right - The right operand.
1188
+ * @returns A `BitwiseExpressionNode`.
1031
1189
  */
1032
1190
  declare const bitOr: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1033
1191
  /**
1034
- * Creates a bitwise XOR expression (left ^ right)
1192
+ * Creates a bitwise XOR expression (`left ^ right`).
1193
+ *
1194
+ * @param left - The left operand.
1195
+ * @param right - The right operand.
1196
+ * @returns A `BitwiseExpressionNode`.
1035
1197
  */
1036
1198
  declare const bitXor: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1037
1199
  /**
1038
- * Creates a bitwise shift left expression (left << right)
1200
+ * Creates a bitwise left-shift expression (`left << right`).
1201
+ *
1202
+ * @param left - The left operand.
1203
+ * @param right - The right operand (number of bits).
1204
+ * @returns A `BitwiseExpressionNode`.
1039
1205
  */
1040
1206
  declare const shiftLeft: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1041
1207
  /**
1042
- * Creates a bitwise shift right expression (left >> right)
1208
+ * Creates a bitwise right-shift expression (`left >> right`).
1209
+ *
1210
+ * @param left - The left operand.
1211
+ * @param right - The right operand (number of bits).
1212
+ * @returns A `BitwiseExpressionNode`.
1043
1213
  */
1044
1214
  declare const shiftRight: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1045
1215
  /**
1046
- * Creates a JSON path expression
1047
- * @param col - Source column
1048
- * @param path - JSON path expression
1049
- * @returns JSON path node
1216
+ * Creates a JSON path extraction expression.
1217
+ *
1218
+ * @param col - The source column (should be a JSON/JSONB column).
1219
+ * @param path - The JSON path expression (e.g., '$.address.city').
1220
+ * @returns A `JsonPathNode`.
1221
+ *
1222
+ * @example
1223
+ * jsonPath(users.profile, '$.settings.theme');
1050
1224
  */
1051
1225
  declare const jsonPath: (col: ColumnRef | ColumnNode, path: string) => JsonPathNode;
1052
1226
  /**
1053
- * Creates a CASE expression
1054
- * @param conditions - Array of WHEN-THEN conditions
1055
- * @param elseValue - Optional ELSE value
1056
- * @returns CASE expression node
1227
+ * Creates a CASE expression (`CASE WHEN ... THEN ... ELSE ... END`).
1228
+ *
1229
+ * @param conditions - An array of `{ when, then }` objects.
1230
+ * @param elseValue - Optional value for the `ELSE` clause.
1231
+ * @returns A `CaseExpressionNode`.
1232
+ *
1233
+ * @example
1234
+ * caseWhen([
1235
+ * { when: gt(users.age, 65), then: 'Senior' },
1236
+ * { when: gt(users.age, 18), then: 'Adult' }
1237
+ * ], 'Minor');
1057
1238
  */
1058
1239
  declare const caseWhen: (conditions: {
1059
1240
  when: ExpressionNode;
1060
1241
  then: OperandNode | ColumnRef | string | number | boolean | null;
1061
1242
  }[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
1062
1243
  /**
1063
- * Builds a CAST expression node for casting values to SQL types.
1244
+ * Creates a CAST expression (`CAST(expression AS type)`).
1245
+ *
1246
+ * @param expression - The expression to cast.
1247
+ * @param castType - The target SQL type (e.g., 'VARCHAR', 'INTEGER').
1248
+ * @returns A `CastExpressionNode`.
1249
+ *
1250
+ * @example
1251
+ * cast(users.age, 'VARCHAR');
1064
1252
  */
1065
1253
  declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
1066
1254
  /**
1067
- * Creates an EXISTS expression
1068
- * @param subquery - Subquery to check for existence
1069
- * @returns EXISTS expression node
1255
+ * Creates an EXISTS check (`EXISTS (SELECT ...)`).
1256
+ *
1257
+ * @param subquery - The subquery to check.
1258
+ * @returns An `ExistsExpressionNode`.
1259
+ *
1260
+ * @example
1261
+ * exists(
1262
+ * selectFromEntity(Order).where(eq(orders.userId, users.id))
1263
+ * );
1070
1264
  */
1071
1265
  declare const exists: (subquery: SelectQueryNode) => ExistsExpressionNode;
1072
1266
  /**
1073
- * Creates a NOT EXISTS expression
1074
- * @param subquery - Subquery to check for non-existence
1075
- * @returns NOT EXISTS expression node
1267
+ * Creates a NOT EXISTS check (`NOT EXISTS (SELECT ...)`).
1268
+ *
1269
+ * @param subquery - The subquery to check.
1270
+ * @returns An `ExistsExpressionNode`.
1271
+ *
1272
+ * @example
1273
+ * notExists(
1274
+ * selectFromEntity(Subscription).where(eq(subscriptions.userId, users.id))
1275
+ * );
1076
1276
  */
1077
1277
  declare const notExists: (subquery: SelectQueryNode) => ExistsExpressionNode;
1078
1278
  /**
1079
- * Creates a COLLATE expression (expression COLLATE collationName)
1080
- * @param expression - Expression to be collated
1081
- * @param collation - Collation name
1082
- * @returns COLLATE expression node
1279
+ * Creates a COLLATE expression (`expression COLLATE collation`).
1280
+ *
1281
+ * @param expression - The expression string.
1282
+ * @param collation - The collation name (e.g., 'nocase').
1283
+ * @returns A `CollateExpressionNode`.
1284
+ *
1285
+ * @example
1286
+ * collate(users.email, 'nocase');
1083
1287
  */
1084
1288
  declare const collate: (expression: OperandNode | ColumnRef | string | number | boolean | null, collation: string) => CollateExpressionNode;
1085
1289
 
1086
1290
  /**
1087
- * Creates a ROW_NUMBER window function
1088
- * @returns Window function node for ROW_NUMBER
1291
+ * Creates a ROW_NUMBER window function.
1292
+ *
1293
+ * @returns A `TypedExpression<number>` representing the `ROW_NUMBER` window function.
1089
1294
  */
1090
- declare const rowNumber: () => WindowFunctionNode;
1295
+ declare const rowNumber: () => TypedExpression<number>;
1091
1296
  /**
1092
- * Creates a RANK window function
1093
- * @returns Window function node for RANK
1297
+ * Creates a RANK window function.
1298
+ *
1299
+ * @returns A `TypedExpression<number>` representing the `RANK` window function.
1094
1300
  */
1095
- declare const rank: () => WindowFunctionNode;
1301
+ declare const rank: () => TypedExpression<number>;
1096
1302
  /**
1097
- * Creates a DENSE_RANK window function
1098
- * @returns Window function node for DENSE_RANK
1303
+ * Creates a DENSE_RANK window function.
1304
+ *
1305
+ * @returns A `TypedExpression<number>` representing the `DENSE_RANK` window function.
1099
1306
  */
1100
- declare const denseRank: () => WindowFunctionNode;
1307
+ declare const denseRank: () => TypedExpression<number>;
1101
1308
  /**
1102
- * Creates an NTILE window function
1103
- * @param n - Number of buckets
1104
- * @returns Window function node for NTILE
1309
+ * Creates an NTILE window function.
1310
+ *
1311
+ * @param n - Number of buckets.
1312
+ * @returns A `TypedExpression<number>` representing the `NTILE` window function.
1105
1313
  */
1106
- declare const ntile: (n: number) => WindowFunctionNode;
1314
+ declare const ntile: (n: number) => TypedExpression<number>;
1107
1315
  /**
1108
- * Creates a LAG window function
1109
- * @param col - Column to lag
1110
- * @param offset - Offset (defaults to 1)
1111
- * @param defaultValue - Default value if no row exists
1112
- * @returns Window function node for LAG
1316
+ * Creates a LAG window function.
1317
+ *
1318
+ * @param col - Column or expression to lag.
1319
+ * @param offset - Optional offset (defaults to 1).
1320
+ * @param defaultValue - Optional default value.
1321
+ * @returns A `TypedExpression<T>` representing the `LAG` window function.
1113
1322
  */
1114
- declare const lag: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
1323
+ declare const lag: <T = any>(col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => TypedExpression<T>;
1115
1324
  /**
1116
- * Creates a LEAD window function
1117
- * @param col - Column to lead
1118
- * @param offset - Offset (defaults to 1)
1119
- * @param defaultValue - Default value if no row exists
1120
- * @returns Window function node for LEAD
1325
+ * Creates a LEAD window function.
1326
+ *
1327
+ * @param col - Column or expression to lead.
1328
+ * @param offset - Optional offset (defaults to 1).
1329
+ * @param defaultValue - Optional default value.
1330
+ * @returns A `TypedExpression<T>` representing the `LEAD` window function.
1121
1331
  */
1122
- declare const lead: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
1332
+ declare const lead: <T = any>(col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => TypedExpression<T>;
1123
1333
  /**
1124
- * Creates a FIRST_VALUE window function
1125
- * @param col - Column to get first value from
1126
- * @returns Window function node for FIRST_VALUE
1334
+ * Creates a FIRST_VALUE window function.
1335
+ *
1336
+ * @param col - Column or expression to get first value from.
1337
+ * @returns A `TypedExpression<T>` representing the `FIRST_VALUE` window function.
1127
1338
  */
1128
- declare const firstValue: (col: ColumnRef | ColumnNode) => WindowFunctionNode;
1339
+ declare const firstValue: <T = any>(col: ColumnRef | ColumnNode) => TypedExpression<T>;
1129
1340
  /**
1130
- * Creates a LAST_VALUE window function
1131
- * @param col - Column to get last value from
1132
- * @returns Window function node for LAST_VALUE
1341
+ * Creates a LAST_VALUE window function.
1342
+ *
1343
+ * @param col - Column or expression to get last value from.
1344
+ * @returns A `TypedExpression<T>` representing the `LAST_VALUE` window function.
1133
1345
  */
1134
- declare const lastValue: (col: ColumnRef | ColumnNode) => WindowFunctionNode;
1346
+ declare const lastValue: <T = any>(col: ColumnRef | ColumnNode) => TypedExpression<T>;
1135
1347
  /**
1136
- * Creates a custom window function
1137
- * @param name - Window function name
1138
- * @param args - Function arguments
1139
- * @param partitionBy - Optional PARTITION BY columns
1140
- * @param orderBy - Optional ORDER BY clauses
1141
- * @returns Window function node
1348
+ * Creates a custom window function.
1349
+ *
1350
+ * @param name - Window function name.
1351
+ * @param args - Function arguments.
1352
+ * @param partitionBy - Optional PARTITION BY columns.
1353
+ * @param orderBy - Optional ORDER BY clauses.
1354
+ * @returns A `TypedExpression<T>` representing the window function.
1142
1355
  */
1143
- declare const windowFunction: (name: string, args?: (ColumnRef | ColumnNode | LiteralNode | JsonPathNode)[], partitionBy?: (ColumnRef | ColumnNode)[], orderBy?: {
1356
+ declare const windowFunction: <T = any>(name: string, args?: (ColumnRef | ColumnNode | LiteralNode | JsonPathNode)[], partitionBy?: (ColumnRef | ColumnNode)[], orderBy?: {
1144
1357
  column: ColumnRef | ColumnNode;
1145
1358
  direction: OrderDirection;
1146
- }[]) => WindowFunctionNode;
1359
+ }[]) => TypedExpression<T>;
1147
1360
 
1148
1361
  /**
1149
1362
  * Creates a COUNT function expression
1150
1363
  * @param col - Column to count
1151
1364
  * @returns Function node with COUNT
1152
1365
  */
1153
- declare const count: (col: ColumnRef | ColumnNode) => FunctionNode;
1366
+ declare const count: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1154
1367
  /**
1155
1368
  * Creates a SUM function expression
1156
1369
  * @param col - Column to sum
1157
1370
  * @returns Function node with SUM
1158
1371
  */
1159
- declare const sum: (col: ColumnRef | ColumnNode) => FunctionNode;
1372
+ declare const sum: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1160
1373
  /**
1161
1374
  * Creates an AVG function expression
1162
1375
  * @param col - Column to average
1163
1376
  * @returns Function node with AVG
1164
1377
  */
1165
- declare const avg: (col: ColumnRef | ColumnNode) => FunctionNode;
1378
+ declare const avg: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1166
1379
  /**
1167
1380
  * Creates a MIN function expression
1168
1381
  * @param col - Column to take the minimum of
1169
1382
  * @returns Function node with MIN
1170
1383
  */
1171
- declare const min: (col: ColumnRef | ColumnNode) => FunctionNode;
1384
+ declare const min: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1172
1385
  /**
1173
1386
  * Creates a MAX function expression
1174
1387
  * @param col - Column to take the maximum of
1175
1388
  * @returns Function node with MAX
1176
1389
  */
1177
- declare const max: (col: ColumnRef | ColumnNode) => FunctionNode;
1390
+ declare const max: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1178
1391
  /**
1179
1392
  * Creates a COUNT(*) function expression.
1180
- * @returns Function node with COUNT(*)
1393
+ *
1394
+ * @returns A `TypedExpression<number>` representing the `COUNT(*)` SQL function.
1181
1395
  */
1182
- declare const countAll: () => FunctionNode;
1396
+ declare const countAll: () => TypedExpression<number>;
1183
1397
  type GroupConcatOrderByInput = {
1184
1398
  column: ColumnRef | ColumnNode;
1185
1399
  direction?: OrderDirection;
@@ -1190,20 +1404,27 @@ type GroupConcatOptions = {
1190
1404
  };
1191
1405
  /**
1192
1406
  * Aggregates grouped strings into a single value.
1407
+ *
1408
+ * @param col - Column or expression to aggregate.
1409
+ * @param options - Optional separator and ordering.
1410
+ * @returns A `TypedExpression<string>` representing the `GROUP_CONCAT` SQL function.
1411
+ *
1412
+ * @example
1413
+ * groupConcat(users.name, { separator: ', ', orderBy: [{ column: users.name }] });
1193
1414
  */
1194
- declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => FunctionNode;
1415
+ declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => TypedExpression<string>;
1195
1416
  /**
1196
1417
  * Creates a STDDEV function expression
1197
1418
  * @param col - Column to calculate standard deviation for
1198
1419
  * @returns Function node with STDDEV
1199
1420
  */
1200
- declare const stddev: (col: ColumnRef | ColumnNode) => FunctionNode;
1421
+ declare const stddev: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1201
1422
  /**
1202
1423
  * Creates a VARIANCE function expression
1203
1424
  * @param col - Column to calculate variance for
1204
1425
  * @returns Function node with VARIANCE
1205
1426
  */
1206
- declare const variance: (col: ColumnRef | ColumnNode) => FunctionNode;
1427
+ declare const variance: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1207
1428
 
1208
1429
  /**
1209
1430
  * Visitor for expression nodes
@@ -1274,6 +1495,16 @@ declare const toColumnRef: (col: ColumnRef | ColumnDef) => ColumnRef;
1274
1495
  */
1275
1496
  declare const toTableRef: (table: TableRef | TableDef) => TableRef;
1276
1497
 
1498
+ /**
1499
+ * Expression AST nodes and builders.
1500
+ * Re-exports components for building and visiting SQL expression trees.
1501
+ */
1502
+
1503
+ type TypedExpression<T> = (FunctionNode | CaseExpressionNode | WindowFunctionNode) & {
1504
+ __tsType: T;
1505
+ };
1506
+ declare const asType: <T>(expr: FunctionNode | CaseExpressionNode | WindowFunctionNode) => TypedExpression<T>;
1507
+
1277
1508
  /**
1278
1509
  * AST node representing a JOIN clause
1279
1510
  */
@@ -3494,7 +3725,12 @@ type RelationCallback = <TChildTable extends TableDef>(qb: SelectQueryBuilder<un
3494
3725
 
3495
3726
  type SelectDialectInput = Dialect | DialectKey;
3496
3727
 
3497
- type ColumnSelectionValue = ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode;
3728
+ type ColumnSelectionValue = ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode | TypedExpression<unknown>;
3729
+ type SelectionValueType<TValue> = TValue extends TypedExpression<infer TRuntime> ? TRuntime : TValue extends ColumnDef ? ColumnToTs<TValue> : unknown;
3730
+ type SelectionResult<TSelection extends Record<string, ColumnSelectionValue>> = {
3731
+ [K in keyof TSelection]: SelectionValueType<TSelection[K]>;
3732
+ };
3733
+ type SelectionFromKeys<TTable extends TableDef, K extends keyof TTable['columns'] & string> = Pick<InferRow<TTable>, K>;
3498
3734
  type DeepSelectEntry<TTable extends TableDef> = {
3499
3735
  type: 'root';
3500
3736
  columns: (keyof TTable['columns'] & string)[];
@@ -3509,7 +3745,7 @@ type DeepSelectConfig<TTable extends TableDef> = DeepSelectEntry<TTable>[];
3509
3745
  * @typeParam T - Result type for projections (unused)
3510
3746
  * @typeParam TTable - Table definition being queried
3511
3747
  */
3512
- declare class SelectQueryBuilder<T = EntityInstance<any>, TTable extends TableDef = TableDef> {
3748
+ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends TableDef = TableDef> {
3513
3749
  private readonly env;
3514
3750
  private readonly context;
3515
3751
  private readonly columnSelector;
@@ -3530,7 +3766,7 @@ declare class SelectQueryBuilder<T = EntityInstance<any>, TTable extends TableDe
3530
3766
  * @param hydration - Optional hydration manager
3531
3767
  * @param dependencies - Optional query builder dependencies
3532
3768
  */
3533
- constructor(table: TTable, state?: SelectQueryState, hydration?: HydrationManager, dependencies?: Partial<SelectQueryBuilderDependencies>, lazyRelations?: Set<string>, lazyRelationOptions?: Map<string, RelationIncludeOptions>, entityConstructor?: EntityConstructor<any>);
3769
+ constructor(table: TTable, state?: SelectQueryState, hydration?: HydrationManager, dependencies?: Partial<SelectQueryBuilderDependencies>, lazyRelations?: Set<string>, lazyRelationOptions?: Map<string, RelationIncludeOptions>, entityConstructor?: EntityConstructor);
3534
3770
  /**
3535
3771
  * Creates a new SelectQueryBuilder instance with updated context and lazy relations
3536
3772
  * @param context - Updated query context
@@ -3580,8 +3816,8 @@ declare class SelectQueryBuilder<T = EntityInstance<any>, TTable extends TableDe
3580
3816
  * fullName: concat(userTable.columns.firstName, ' ', userTable.columns.lastName)
3581
3817
  * });
3582
3818
  */
3583
- select<K extends keyof TTable['columns'] & string>(...args: K[]): SelectQueryBuilder<T, TTable>;
3584
- select(columns: Record<string, ColumnSelectionValue>): SelectQueryBuilder<T, TTable>;
3819
+ select<K extends keyof TTable['columns'] & string>(...args: K[]): SelectQueryBuilder<T & SelectionFromKeys<TTable, K>, TTable>;
3820
+ select<TSelection extends Record<string, ColumnSelectionValue>>(columns: TSelection): SelectQueryBuilder<T & SelectionResult<TSelection>, TTable>;
3585
3821
  /**
3586
3822
  * Selects raw column expressions
3587
3823
  * @param cols - Column expressions as strings
@@ -3670,7 +3906,7 @@ declare class SelectQueryBuilder<T = EntityInstance<any>, TTable extends TableDe
3670
3906
  * qb.select('id', 'name')
3671
3907
  * .selectSubquery('postCount', postCount);
3672
3908
  */
3673
- selectSubquery<TSub extends TableDef>(alias: string, sub: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3909
+ selectSubquery<TValue = unknown, K extends string = string, TSub extends TableDef = TableDef>(alias: K, sub: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T & Record<K, TValue>, TTable>;
3674
3910
  /**
3675
3911
  * Adds a JOIN against a derived table (subquery with alias)
3676
3912
  * @param subquery - Subquery to join
@@ -4997,598 +5233,766 @@ declare const getSchemaIntrospector: (dialect: DialectName) => SchemaIntrospecto
4997
5233
  type OperandInput$5 = OperandNode | ColumnDef | string | number | boolean | null;
4998
5234
  /**
4999
5235
  * Converts a string to lowercase.
5000
- * @param value - The string value.
5001
- * @returns A FunctionNode representing the LOWER SQL function.
5236
+ *
5237
+ * @param value - The string value or column.
5238
+ * @returns A `TypedExpression<string>` representing the `LOWER` SQL function.
5239
+ *
5240
+ * @example
5241
+ * lower(users.email);
5002
5242
  */
5003
- declare const lower: (value: OperandInput$5) => FunctionNode;
5243
+ declare const lower: (value: OperandInput$5) => TypedExpression<string>;
5004
5244
  /**
5005
5245
  * Converts a string to uppercase.
5006
- * @param value - The string value.
5007
- * @returns A FunctionNode representing the UPPER SQL function.
5246
+ *
5247
+ * @param value - The string value or column.
5248
+ * @returns A `TypedExpression<string>` representing the `UPPER` SQL function.
5249
+ *
5250
+ * @example
5251
+ * upper(users.firstName);
5008
5252
  */
5009
- declare const upper: (value: OperandInput$5) => FunctionNode;
5253
+ declare const upper: (value: OperandInput$5) => TypedExpression<string>;
5010
5254
  /**
5011
5255
  * Returns the ASCII code of the first character of a string.
5012
- * @param value - The string value.
5013
- * @returns A FunctionNode representing the ASCII SQL function.
5256
+ *
5257
+ * @param value - The string value or column.
5258
+ * @returns A `TypedExpression<number>` representing the `ASCII` SQL function.
5259
+ *
5260
+ * @example
5261
+ * ascii(users.initial);
5014
5262
  */
5015
- declare const ascii: (value: OperandInput$5) => FunctionNode;
5263
+ declare const ascii: (value: OperandInput$5) => TypedExpression<number>;
5016
5264
  /**
5017
5265
  * Returns a string from one or more ASCII codes.
5018
- * @param codes - The ASCII codes.
5019
- * @returns A FunctionNode representing the CHAR SQL function.
5266
+ *
5267
+ * @param codes - One or more ASCII codes.
5268
+ * @returns A `TypedExpression<string>` representing the `CHAR` SQL function.
5269
+ *
5270
+ * @example
5271
+ * char(65, 66, 67); // 'ABC'
5020
5272
  */
5021
- declare const char: (...codes: OperandInput$5[]) => FunctionNode;
5273
+ declare const char: (...codes: OperandInput$5[]) => TypedExpression<string>;
5022
5274
  /**
5023
5275
  * Returns the number of characters in a string.
5024
- * @param value - The string value.
5025
- * @returns A FunctionNode representing the CHAR_LENGTH SQL function.
5276
+ *
5277
+ * @param value - The string value or column.
5278
+ * @returns A `TypedExpression<number>` representing the `CHAR_LENGTH` SQL function.
5279
+ *
5280
+ * @example
5281
+ * charLength(users.bio);
5026
5282
  */
5027
- declare const charLength: (value: OperandInput$5) => FunctionNode;
5283
+ declare const charLength: (value: OperandInput$5) => TypedExpression<number>;
5028
5284
  /**
5029
5285
  * Returns the length of a string in bytes or characters.
5030
- * @param value - The string value.
5031
- * @returns A FunctionNode representing the LENGTH SQL function.
5286
+ *
5287
+ * @param value - The string value or column.
5288
+ * @returns A `TypedExpression<number>` representing the `LENGTH` SQL function.
5289
+ *
5290
+ * @example
5291
+ * length(users.password);
5032
5292
  */
5033
- declare const length: (value: OperandInput$5) => FunctionNode;
5293
+ declare const length: (value: OperandInput$5) => TypedExpression<number>;
5034
5294
  /**
5035
5295
  * Removes leading and trailing whitespace or specified characters from a string.
5036
- * @param value - The string value.
5037
- * @param chars - The characters to trim (optional).
5038
- * @returns A FunctionNode representing the TRIM SQL function.
5296
+ *
5297
+ * @param value - The string value or column.
5298
+ * @param chars - Optional characters to trim.
5299
+ * @returns A `TypedExpression<string>` representing the `TRIM` SQL function.
5300
+ *
5301
+ * @example
5302
+ * trim(users.name);
5303
+ * trim(users.path, '/');
5039
5304
  */
5040
- declare const trim: (value: OperandInput$5, chars?: OperandInput$5) => FunctionNode;
5305
+ declare const trim: (value: OperandInput$5, chars?: OperandInput$5) => TypedExpression<string>;
5041
5306
  /**
5042
5307
  * Removes leading whitespace from a string.
5043
- * @param value - The string value.
5044
- * @returns A FunctionNode representing the LTRIM SQL function.
5308
+ *
5309
+ * @param value - The string value or column.
5310
+ * @returns A `TypedExpression<string>` representing the `LTRIM` SQL function.
5045
5311
  */
5046
- declare const ltrim: (value: OperandInput$5) => FunctionNode;
5312
+ declare const ltrim: (value: OperandInput$5) => TypedExpression<string>;
5047
5313
  /**
5048
5314
  * Removes trailing whitespace from a string.
5049
- * @param value - The string value.
5050
- * @returns A FunctionNode representing the RTRIM SQL function.
5315
+ *
5316
+ * @param value - The string value or column.
5317
+ * @returns A `TypedExpression<string>` representing the `RTRIM` SQL function.
5051
5318
  */
5052
- declare const rtrim: (value: OperandInput$5) => FunctionNode;
5319
+ declare const rtrim: (value: OperandInput$5) => TypedExpression<string>;
5053
5320
  /**
5054
5321
  * Concatenates two or more strings.
5055
- * @param args - The strings to concatenate.
5056
- * @returns A FunctionNode representing the CONCAT SQL function.
5322
+ *
5323
+ * @param args - The strings or columns to concatenate.
5324
+ * @returns A `TypedExpression<string>` representing the `CONCAT` SQL function.
5325
+ *
5326
+ * @example
5327
+ * concat(users.firstName, ' ', users.lastName);
5057
5328
  */
5058
- declare const concat: (...args: OperandInput$5[]) => FunctionNode;
5329
+ declare const concat: (...args: OperandInput$5[]) => TypedExpression<string>;
5059
5330
  /**
5060
5331
  * Concatenates strings with a separator.
5332
+ *
5061
5333
  * @param separator - The separator string.
5062
- * @param args - The strings to concatenate.
5063
- * @returns A FunctionNode representing the CONCAT_WS SQL function.
5334
+ * @param args - The strings or columns to concatenate.
5335
+ * @returns A `TypedExpression<string>` representing the `CONCAT_WS` SQL function.
5336
+ *
5337
+ * @example
5338
+ * concatWs(', ', users.lastName, users.firstName);
5064
5339
  */
5065
- declare const concatWs: (separator: OperandInput$5, ...args: OperandInput$5[]) => FunctionNode;
5340
+ declare const concatWs: (separator: OperandInput$5, ...args: OperandInput$5[]) => TypedExpression<string>;
5066
5341
  /**
5067
5342
  * Extracts a substring from a string.
5068
- * @param value - The string value.
5069
- * @param start - The starting position.
5070
- * @param length - The length of the substring (optional).
5071
- * @returns A FunctionNode representing the SUBSTR SQL function.
5343
+ *
5344
+ * @param value - The input string or column.
5345
+ * @param start - The starting position (1-indexed).
5346
+ * @param length - Optional length of the substring.
5347
+ * @returns A `TypedExpression<string>` representing the `SUBSTR` SQL function.
5348
+ *
5349
+ * @example
5350
+ * substr(users.token, 1, 8);
5072
5351
  */
5073
- declare const substr: (value: OperandInput$5, start: OperandInput$5, length?: OperandInput$5) => FunctionNode;
5352
+ declare const substr: (value: OperandInput$5, start: OperandInput$5, length?: OperandInput$5) => TypedExpression<string>;
5074
5353
  /**
5075
5354
  * Returns the leftmost characters of a string.
5076
- * @param value - The string value.
5077
- * @param len - The number of characters to return.
5078
- * @returns A FunctionNode representing the LEFT SQL function.
5355
+ *
5356
+ * @param value - The string value or column.
5357
+ * @param len - Number of characters to return.
5358
+ * @returns A `TypedExpression<string>` representing the `LEFT` SQL function.
5079
5359
  */
5080
- declare const left: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
5360
+ declare const left: (value: OperandInput$5, len: OperandInput$5) => TypedExpression<string>;
5081
5361
  /**
5082
5362
  * Returns the rightmost characters of a string.
5083
- * @param value - The string value.
5084
- * @param len - The number of characters to return.
5085
- * @returns A FunctionNode representing the RIGHT SQL function.
5363
+ *
5364
+ * @param value - The string value or column.
5365
+ * @param len - Number of characters to return.
5366
+ * @returns A `TypedExpression<string>` representing the `RIGHT` SQL function.
5086
5367
  */
5087
- declare const right: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
5368
+ declare const right: (value: OperandInput$5, len: OperandInput$5) => TypedExpression<string>;
5088
5369
  /**
5089
5370
  * Returns the position of a substring in a string.
5371
+ *
5090
5372
  * @param substring - The substring to search for.
5091
- * @param value - The string to search in.
5092
- * @returns A FunctionNode representing the POSITION SQL function.
5373
+ * @param value - The string or column to search within.
5374
+ * @returns A `TypedExpression<number>` representing the `POSITION` SQL function.
5093
5375
  */
5094
- declare const position: (substring: OperandInput$5, value: OperandInput$5) => FunctionNode;
5376
+ declare const position: (substring: OperandInput$5, value: OperandInput$5) => TypedExpression<number>;
5095
5377
  /**
5096
5378
  * Returns the position of a substring in a string.
5097
- * @param value - The string to search in.
5379
+ *
5380
+ * @param value - The string or column to search within.
5098
5381
  * @param substring - The substring to search for.
5099
- * @returns A FunctionNode representing the INSTR SQL function.
5382
+ * @returns A `TypedExpression<number>` representing the `INSTR` SQL function.
5100
5383
  */
5101
- declare const instr: (value: OperandInput$5, substring: OperandInput$5) => FunctionNode;
5384
+ declare const instr: (value: OperandInput$5, substring: OperandInput$5) => TypedExpression<number>;
5102
5385
  /**
5103
5386
  * Returns the position of a substring in a string, optionally starting from a position.
5104
- * @param substring - The substring to search for.
5105
- * @param value - The string to search in.
5106
- * @param start - The starting position (optional).
5107
- * @returns A FunctionNode representing the LOCATE SQL function.
5387
+ *
5388
+ * @param substring - Substring to find.
5389
+ * @param value - String/column to search.
5390
+ * @param start - Optional starting position.
5391
+ * @returns A `TypedExpression<number>` representing the `LOCATE` SQL function.
5108
5392
  */
5109
- declare const locate: (substring: OperandInput$5, value: OperandInput$5, start?: OperandInput$5) => FunctionNode;
5393
+ declare const locate: (substring: OperandInput$5, value: OperandInput$5, start?: OperandInput$5) => TypedExpression<number>;
5110
5394
  /**
5111
5395
  * Replaces occurrences of a substring in a string.
5112
- * @param value - The string to search in.
5113
- * @param search - The substring to replace.
5114
- * @param replacement - The replacement string.
5115
- * @returns A FunctionNode representing the REPLACE SQL function.
5396
+ *
5397
+ * @param value - The original string or column.
5398
+ * @param search - Substring to search for.
5399
+ * @param replacement - Replacement string.
5400
+ * @returns A `TypedExpression<string>` representing the `REPLACE` SQL function.
5401
+ *
5402
+ * @example
5403
+ * replace(users.email, 'old.com', 'new.com');
5116
5404
  */
5117
- declare const replace: (value: OperandInput$5, search: OperandInput$5, replacement: OperandInput$5) => FunctionNode;
5405
+ declare const replace: (value: OperandInput$5, search: OperandInput$5, replacement: OperandInput$5) => TypedExpression<string>;
5118
5406
  /**
5119
5407
  * Repeats a string a specified number of times.
5408
+ *
5120
5409
  * @param value - The string to repeat.
5121
- * @param count - The number of times to repeat.
5122
- * @returns A FunctionNode representing the REPEAT SQL function.
5410
+ * @param count - How many times to repeat.
5411
+ * @returns A `TypedExpression<string>` representing the `REPEAT` SQL function.
5123
5412
  */
5124
- declare const repeat: (value: OperandInput$5, count: OperandInput$5) => FunctionNode;
5413
+ declare const repeat: (value: OperandInput$5, count: OperandInput$5) => TypedExpression<string>;
5125
5414
  /**
5126
5415
  * Left-pads a string to a certain length with another string.
5127
- * @param value - The string to pad.
5128
- * @param len - The length to pad to.
5129
- * @param pad - The padding string.
5130
- * @returns A FunctionNode representing the LPAD SQL function.
5416
+ *
5417
+ * @param value - The string/column to pad.
5418
+ * @param len - Target length.
5419
+ * @param pad - Padding string.
5420
+ * @returns A `TypedExpression<string>` representing the `LPAD` SQL function.
5131
5421
  */
5132
- declare const lpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
5422
+ declare const lpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => TypedExpression<string>;
5133
5423
  /**
5134
5424
  * Right-pads a string to a certain length with another string.
5135
- * @param value - The string to pad.
5136
- * @param len - The length to pad to.
5137
- * @param pad - The padding string.
5138
- * @returns A FunctionNode representing the RPAD SQL function.
5425
+ *
5426
+ * @param value - The string/column to pad.
5427
+ * @param len - Target length.
5428
+ * @param pad - Padding string.
5429
+ * @returns A `TypedExpression<string>` representing the `RPAD` SQL function.
5139
5430
  */
5140
- declare const rpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
5431
+ declare const rpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => TypedExpression<string>;
5141
5432
  /**
5142
5433
  * Returns a string consisting of a specified number of spaces.
5143
- * @param count - The number of spaces.
5144
- * @returns A FunctionNode representing the SPACE SQL function.
5434
+ *
5435
+ * @param count - Number of spaces.
5436
+ * @returns A `TypedExpression<string>` representing the `SPACE` SQL function.
5145
5437
  */
5146
- declare const space: (count: OperandInput$5) => FunctionNode;
5438
+ declare const space: (count: OperandInput$5) => TypedExpression<string>;
5147
5439
  /**
5148
5440
  * Reverses a string.
5149
- * @param value - The string value.
5150
- * @returns A FunctionNode representing the REVERSE SQL function.
5441
+ *
5442
+ * @param value - The string value or column.
5443
+ * @returns A `TypedExpression<string>` representing the `REVERSE` SQL function.
5151
5444
  */
5152
- declare const reverse: (value: OperandInput$5) => FunctionNode;
5445
+ declare const reverse: (value: OperandInput$5) => TypedExpression<string>;
5153
5446
  /**
5154
5447
  * Capitalizes the first letter of each word in a string.
5155
- * @param value - The string value.
5156
- * @returns A FunctionNode representing the INITCAP SQL function.
5448
+ *
5449
+ * @param value - The string value or column.
5450
+ * @returns A `TypedExpression<string>` representing the `INITCAP` SQL function.
5157
5451
  */
5158
- declare const initcap: (value: OperandInput$5) => FunctionNode;
5452
+ declare const initcap: (value: OperandInput$5) => TypedExpression<string>;
5159
5453
  /**
5160
5454
  * Returns the MD5 hash of a string.
5161
- * @param value - The string value.
5162
- * @returns A FunctionNode representing the MD5 SQL function.
5455
+ *
5456
+ * @param value - The string value or column.
5457
+ * @returns A `TypedExpression<string>` representing the `MD5` SQL function.
5163
5458
  */
5164
- declare const md5: (value: OperandInput$5) => FunctionNode;
5459
+ declare const md5: (value: OperandInput$5) => TypedExpression<string>;
5165
5460
  /**
5166
5461
  * Returns the SHA-1 hash of a string.
5167
- * @param value - The string value.
5168
- * @returns A FunctionNode representing the SHA1 SQL function.
5462
+ *
5463
+ * @param value - The string value or column.
5464
+ * @returns A `TypedExpression<string>` representing the `SHA1` SQL function.
5169
5465
  */
5170
- declare const sha1: (value: OperandInput$5) => FunctionNode;
5466
+ declare const sha1: (value: OperandInput$5) => TypedExpression<string>;
5171
5467
  /**
5172
5468
  * Returns the SHA-2 hash of a string with a specified bit length.
5173
- * @param value - The string value.
5174
- * @param bits - The bit length (e.g., 224, 256, 384, 512).
5175
- * @returns A FunctionNode representing the SHA2 SQL function.
5469
+ *
5470
+ * @param value - The input.
5471
+ * @param bits - Bit length (e.g., 256, 512).
5472
+ * @returns A `TypedExpression<string>` representing the `SHA2` SQL function.
5176
5473
  */
5177
- declare const sha2: (value: OperandInput$5, bits: OperandInput$5) => FunctionNode;
5474
+ declare const sha2: (value: OperandInput$5, bits: OperandInput$5) => TypedExpression<string>;
5178
5475
  /**
5179
5476
  * Returns the length of a string in bits.
5180
- * @param value - The string value.
5181
- * @returns A FunctionNode representing the BIT_LENGTH SQL function.
5477
+ *
5478
+ * @param value - String value or column.
5479
+ * @returns A `TypedExpression<number>` representing the `BIT_LENGTH` SQL function.
5182
5480
  */
5183
- declare const bitLength: (value: OperandInput$5) => FunctionNode;
5481
+ declare const bitLength: (value: OperandInput$5) => TypedExpression<number>;
5184
5482
  /**
5185
5483
  * Returns the length of a string in bytes.
5186
- * @param value - The string value.
5187
- * @returns A FunctionNode representing the OCTET_LENGTH SQL function.
5484
+ *
5485
+ * @param value - String value or column.
5486
+ * @returns A `TypedExpression<number>` representing the `OCTET_LENGTH` SQL function.
5188
5487
  */
5189
- declare const octetLength: (value: OperandInput$5) => FunctionNode;
5488
+ declare const octetLength: (value: OperandInput$5) => TypedExpression<number>;
5190
5489
  /**
5191
5490
  * Returns a string from an ASCII code.
5192
- * @param code - The ASCII code.
5193
- * @returns A FunctionNode representing the CHR/CHAR SQL function.
5491
+ *
5492
+ * @param code - ASCII code.
5493
+ * @returns A `TypedExpression<string>` representing the `CHR` SQL function.
5194
5494
  */
5195
- declare const chr: (code: OperandInput$5) => FunctionNode;
5495
+ declare const chr: (code: OperandInput$5) => TypedExpression<string>;
5196
5496
 
5197
5497
  type OperandInput$4 = OperandNode | ColumnDef | string | number | boolean | null;
5198
5498
  /**
5199
5499
  * Returns the absolute value of a number.
5200
- * @param value - The numeric value.
5201
- * @returns A FunctionNode representing the ABS SQL function.
5500
+ *
5501
+ * @param value - The numeric value or column.
5502
+ * @returns A `TypedExpression<number>` representing the `ABS` SQL function.
5503
+ *
5504
+ * @example
5505
+ * abs(transactions.amount);
5202
5506
  */
5203
- declare const abs: (value: OperandInput$4) => FunctionNode;
5507
+ declare const abs: (value: OperandInput$4) => TypedExpression<number>;
5204
5508
  /**
5205
5509
  * Returns the arccosine (inverse cosine) of a number.
5206
- * @param value - The numeric value.
5207
- * @returns A FunctionNode representing the ACOS SQL function.
5510
+ *
5511
+ * @param value - The numeric value or column.
5512
+ * @returns A `TypedExpression<number>` representing the `ACOS` SQL function.
5208
5513
  */
5209
- declare const acos: (value: OperandInput$4) => FunctionNode;
5514
+ declare const acos: (value: OperandInput$4) => TypedExpression<number>;
5210
5515
  /**
5211
5516
  * Returns the arcsine (inverse sine) of a number.
5212
- * @param value - The numeric value.
5213
- * @returns A FunctionNode representing the ASIN SQL function.
5517
+ *
5518
+ * @param value - The numeric value or column.
5519
+ * @returns A `TypedExpression<number>` representing the `ASIN` SQL function.
5214
5520
  */
5215
- declare const asin: (value: OperandInput$4) => FunctionNode;
5521
+ declare const asin: (value: OperandInput$4) => TypedExpression<number>;
5216
5522
  /**
5217
5523
  * Returns the arctangent (inverse tangent) of a number.
5218
- * @param value - The numeric value.
5219
- * @returns A FunctionNode representing the ATAN SQL function.
5524
+ *
5525
+ * @param value - The numeric value or column.
5526
+ * @returns A `TypedExpression<number>` representing the `ATAN` SQL function.
5220
5527
  */
5221
- declare const atan: (value: OperandInput$4) => FunctionNode;
5528
+ declare const atan: (value: OperandInput$4) => TypedExpression<number>;
5222
5529
  /**
5223
5530
  * Returns the arctangent of the two arguments.
5531
+ *
5224
5532
  * @param y - The y-coordinate.
5225
5533
  * @param x - The x-coordinate.
5226
- * @returns A FunctionNode representing the ATAN2 SQL function.
5534
+ * @returns A `TypedExpression<number>` representing the `ATAN2` SQL function.
5227
5535
  */
5228
- declare const atan2: (y: OperandInput$4, x: OperandInput$4) => FunctionNode;
5536
+ declare const atan2: (y: OperandInput$4, x: OperandInput$4) => TypedExpression<number>;
5229
5537
  /**
5230
5538
  * Returns the smallest integer greater than or equal to a number.
5231
- * @param value - The numeric value.
5232
- * @returns A FunctionNode representing the CEIL SQL function.
5539
+ *
5540
+ * @param value - The numeric value or column.
5541
+ * @returns A `TypedExpression<number>` representing the `CEIL` SQL function.
5233
5542
  */
5234
- declare const ceil: (value: OperandInput$4) => FunctionNode;
5543
+ declare const ceil: (value: OperandInput$4) => TypedExpression<number>;
5235
5544
  /**
5236
5545
  * Alias for ceil. Returns the smallest integer greater than or equal to a number.
5237
- * @param value - The numeric value.
5238
- * @returns A FunctionNode representing the CEILING SQL function.
5546
+ *
5547
+ * @param value - The numeric value or column.
5548
+ * @returns A `TypedExpression<number>` representing the `CEILING` SQL function.
5239
5549
  */
5240
- declare const ceiling: (value: OperandInput$4) => FunctionNode;
5550
+ declare const ceiling: (value: OperandInput$4) => TypedExpression<number>;
5241
5551
  /**
5242
5552
  * Returns the cosine of a number (in radians).
5553
+ *
5243
5554
  * @param value - The numeric value in radians.
5244
- * @returns A FunctionNode representing the COS SQL function.
5555
+ * @returns A `TypedExpression<number>` representing the `COS` SQL function.
5245
5556
  */
5246
- declare const cos: (value: OperandInput$4) => FunctionNode;
5557
+ declare const cos: (value: OperandInput$4) => TypedExpression<number>;
5247
5558
  /**
5248
5559
  * Returns the cotangent of a number.
5560
+ *
5249
5561
  * @param value - The numeric value.
5250
- * @returns A FunctionNode representing the COT SQL function.
5562
+ * @returns A `TypedExpression<number>` representing the `COT` SQL function.
5251
5563
  */
5252
- declare const cot: (value: OperandInput$4) => FunctionNode;
5564
+ declare const cot: (value: OperandInput$4) => TypedExpression<number>;
5253
5565
  /**
5254
5566
  * Converts radians to degrees.
5567
+ *
5255
5568
  * @param value - The angle in radians.
5256
- * @returns A FunctionNode representing the DEGREES SQL function.
5569
+ * @returns A `TypedExpression<number>` representing the `DEGREES` SQL function.
5257
5570
  */
5258
- declare const degrees: (value: OperandInput$4) => FunctionNode;
5571
+ declare const degrees: (value: OperandInput$4) => TypedExpression<number>;
5259
5572
  /**
5260
5573
  * Returns e raised to the power of the argument.
5574
+ *
5261
5575
  * @param value - The exponent.
5262
- * @returns A FunctionNode representing the EXP SQL function.
5576
+ * @returns A `TypedExpression<number>` representing the `EXP` SQL function.
5263
5577
  */
5264
- declare const exp: (value: OperandInput$4) => FunctionNode;
5578
+ declare const exp: (value: OperandInput$4) => TypedExpression<number>;
5265
5579
  /**
5266
5580
  * Returns the largest integer less than or equal to a number.
5581
+ *
5267
5582
  * @param value - The numeric value.
5268
- * @returns A FunctionNode representing the FLOOR SQL function.
5583
+ * @returns A `TypedExpression<number>` representing the `FLOOR` SQL function.
5269
5584
  */
5270
- declare const floor: (value: OperandInput$4) => FunctionNode;
5585
+ declare const floor: (value: OperandInput$4) => TypedExpression<number>;
5271
5586
  /**
5272
5587
  * Returns the natural logarithm (base e) of a number.
5588
+ *
5273
5589
  * @param value - The numeric value.
5274
- * @returns A FunctionNode representing the LN SQL function.
5590
+ * @returns A `TypedExpression<number>` representing the `LN` SQL function.
5275
5591
  */
5276
- declare const ln: (value: OperandInput$4) => FunctionNode;
5592
+ declare const ln: (value: OperandInput$4) => TypedExpression<number>;
5277
5593
  /**
5278
5594
  * Returns the base-10 logarithm of a number.
5595
+ *
5279
5596
  * @param value - The numeric value.
5280
- * @returns A FunctionNode representing the LOG SQL function.
5597
+ * @returns A `TypedExpression<number>` representing the `LOG` SQL function.
5281
5598
  */
5282
- declare const log: (value: OperandInput$4) => FunctionNode;
5599
+ declare const log: (value: OperandInput$4) => TypedExpression<number>;
5283
5600
  /**
5284
5601
  * Returns the base-10 logarithm of a number.
5602
+ *
5285
5603
  * @param value - The numeric value.
5286
- * @returns A FunctionNode representing the LOG10 SQL function.
5604
+ * @returns A `TypedExpression<number>` representing the `LOG10` SQL function.
5287
5605
  */
5288
- declare const log10: (value: OperandInput$4) => FunctionNode;
5606
+ declare const log10: (value: OperandInput$4) => TypedExpression<number>;
5289
5607
  /**
5290
5608
  * Returns the logarithm of a number for a specific base.
5609
+ *
5291
5610
  * @param base - The base of the logarithm.
5292
5611
  * @param value - The numeric value.
5293
- * @returns A FunctionNode representing the LOG_BASE SQL function.
5612
+ * @returns A `TypedExpression<number>` representing the `LOG_BASE` SQL function.
5294
5613
  */
5295
- declare const logBase: (base: OperandInput$4, value: OperandInput$4) => FunctionNode;
5614
+ declare const logBase: (base: OperandInput$4, value: OperandInput$4) => TypedExpression<number>;
5296
5615
  /**
5297
5616
  * Returns the remainder of dividing x by y.
5617
+ *
5298
5618
  * @param x - The dividend.
5299
5619
  * @param y - The divisor.
5300
- * @returns A FunctionNode representing the MOD SQL function.
5620
+ * @returns A `TypedExpression<number>` representing the `MOD` SQL function.
5301
5621
  */
5302
- declare const mod: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5622
+ declare const mod: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5303
5623
  /**
5304
5624
  * Returns the value of PI (approximately 3.14159...).
5305
- * @returns A FunctionNode representing the PI SQL function.
5625
+ *
5626
+ * @returns A `TypedExpression<number>` representing the `PI` SQL function.
5306
5627
  */
5307
- declare const pi: () => FunctionNode;
5628
+ declare const pi: () => TypedExpression<number>;
5308
5629
  /**
5309
5630
  * Returns x raised to the power of y.
5631
+ *
5310
5632
  * @param x - The base.
5311
5633
  * @param y - The exponent.
5312
- * @returns A FunctionNode representing the POWER SQL function.
5634
+ * @returns A `TypedExpression<number>` representing the `POWER` SQL function.
5313
5635
  */
5314
- declare const power: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5636
+ declare const power: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5315
5637
  /**
5316
5638
  * Alias for power. Returns x raised to the power of y.
5639
+ *
5317
5640
  * @param x - The base.
5318
5641
  * @param y - The exponent.
5319
- * @returns A FunctionNode representing the POW SQL function.
5642
+ * @returns A `TypedExpression<number>` representing the `POW` SQL function.
5320
5643
  */
5321
- declare const pow: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5644
+ declare const pow: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5322
5645
  /**
5323
5646
  * Converts degrees to radians.
5647
+ *
5324
5648
  * @param value - The angle in degrees.
5325
- * @returns A FunctionNode representing the RADIANS SQL function.
5649
+ * @returns A `TypedExpression<number>` representing the `RADIANS` SQL function.
5326
5650
  */
5327
- declare const radians: (value: OperandInput$4) => FunctionNode;
5651
+ declare const radians: (value: OperandInput$4) => TypedExpression<number>;
5328
5652
  /**
5329
5653
  * Returns a random number between 0 and 1.
5330
- * @returns A FunctionNode representing the RANDOM SQL function.
5654
+ *
5655
+ * @returns A `TypedExpression<number>` representing the `RANDOM` SQL function.
5331
5656
  */
5332
- declare const random: () => FunctionNode;
5657
+ declare const random: () => TypedExpression<number>;
5333
5658
  /**
5334
5659
  * Alias for random. Returns a random number between 0 and 1.
5335
- * @returns A FunctionNode representing the RAND SQL function.
5660
+ *
5661
+ * @returns A `TypedExpression<number>` representing the `RAND` SQL function.
5336
5662
  */
5337
- declare const rand: () => FunctionNode;
5663
+ declare const rand: () => TypedExpression<number>;
5338
5664
  /**
5339
5665
  * Rounds a number to a specified number of decimal places.
5666
+ *
5340
5667
  * @param value - The numeric value to round.
5341
- * @param decimals - The number of decimal places (optional).
5342
- * @returns A FunctionNode representing the ROUND SQL function.
5668
+ * @param decimals - Optional number of decimal places.
5669
+ * @returns A `TypedExpression<number>` representing the `ROUND` SQL function.
5343
5670
  */
5344
- declare const round: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
5671
+ declare const round: (value: OperandInput$4, decimals?: OperandInput$4) => TypedExpression<number>;
5345
5672
  /**
5346
5673
  * Returns the sign of a number (-1 for negative, 0 for zero, 1 for positive).
5674
+ *
5347
5675
  * @param value - The numeric value.
5348
- * @returns A FunctionNode representing the SIGN SQL function.
5676
+ * @returns A `TypedExpression<number>` representing the `SIGN` SQL function.
5349
5677
  */
5350
- declare const sign: (value: OperandInput$4) => FunctionNode;
5678
+ declare const sign: (value: OperandInput$4) => TypedExpression<number>;
5351
5679
  /**
5352
5680
  * Returns the sine of a number (in radians).
5681
+ *
5353
5682
  * @param value - The numeric value in radians.
5354
- * @returns A FunctionNode representing the SIN SQL function.
5683
+ * @returns A `TypedExpression<number>` representing the `SIN` SQL function.
5355
5684
  */
5356
- declare const sin: (value: OperandInput$4) => FunctionNode;
5685
+ declare const sin: (value: OperandInput$4) => TypedExpression<number>;
5357
5686
  /**
5358
5687
  * Returns the square root of a number.
5359
- * @param value - The numeric value.
5360
- * @returns A FunctionNode representing the SQRT SQL function.
5688
+ *
5689
+ * @param value - The numeric value or column.
5690
+ * @returns A `TypedExpression<number>` representing the `SQRT` SQL function.
5361
5691
  */
5362
- declare const sqrt: (value: OperandInput$4) => FunctionNode;
5692
+ declare const sqrt: (value: OperandInput$4) => TypedExpression<number>;
5363
5693
  /**
5364
5694
  * Returns the tangent of a number (in radians).
5695
+ *
5365
5696
  * @param value - The numeric value in radians.
5366
- * @returns A FunctionNode representing the TAN SQL function.
5697
+ * @returns A `TypedExpression<number>` representing the `TAN` SQL function.
5367
5698
  */
5368
- declare const tan: (value: OperandInput$4) => FunctionNode;
5699
+ declare const tan: (value: OperandInput$4) => TypedExpression<number>;
5369
5700
  /**
5370
5701
  * Truncates a number to a specified number of decimal places without rounding.
5702
+ *
5371
5703
  * @param value - The numeric value to truncate.
5372
- * @param decimals - The number of decimal places (optional).
5373
- * @returns A FunctionNode representing the TRUNC SQL function.
5704
+ * @param decimals - Optional number of decimal places.
5705
+ * @returns A `TypedExpression<number>` representing the `TRUNC` SQL function.
5374
5706
  */
5375
- declare const trunc: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
5707
+ declare const trunc: (value: OperandInput$4, decimals?: OperandInput$4) => TypedExpression<number>;
5376
5708
  /**
5377
5709
  * Alias for trunc. Truncates a number to a specified number of decimal places without rounding.
5710
+ *
5378
5711
  * @param value - The numeric value to truncate.
5379
5712
  * @param decimals - The number of decimal places.
5380
- * @returns A FunctionNode representing the TRUNCATE SQL function.
5713
+ * @returns A `TypedExpression<number>` representing the `TRUNCATE` SQL function.
5381
5714
  */
5382
- declare const truncate: (value: OperandInput$4, decimals: OperandInput$4) => FunctionNode;
5715
+ declare const truncate: (value: OperandInput$4, decimals: OperandInput$4) => TypedExpression<number>;
5383
5716
  /**
5384
5717
  * Returns the base-2 logarithm of a number.
5385
- * @param value - The numeric value.
5386
- * @returns A FunctionNode representing the LOG2 SQL function.
5718
+ *
5719
+ * @param value - The numeric value or column.
5720
+ * @returns A `TypedExpression<number>` representing the `LOG2` SQL function.
5387
5721
  */
5388
- declare const log2: (value: OperandInput$4) => FunctionNode;
5722
+ declare const log2: (value: OperandInput$4) => TypedExpression<number>;
5389
5723
  /**
5390
5724
  * Returns the cube root of a number.
5391
- * @param value - The numeric value.
5392
- * @returns A FunctionNode representing the CBRT SQL function.
5725
+ *
5726
+ * @param value - The numeric value or column.
5727
+ * @returns A `TypedExpression<number>` representing the `CBRT` SQL function.
5393
5728
  */
5394
- declare const cbrt: (value: OperandInput$4) => FunctionNode;
5729
+ declare const cbrt: (value: OperandInput$4) => TypedExpression<number>;
5395
5730
 
5396
5731
  type OperandInput$3 = OperandNode | ColumnDef | string | number | boolean | null;
5397
5732
  /**
5398
5733
  * Returns the current local date and time.
5399
- * @returns A FunctionNode representing the NOW() SQL function.
5734
+ *
5735
+ * @returns A `TypedExpression<Date>` representing the `NOW()` SQL function.
5400
5736
  */
5401
- declare const now: () => FunctionNode;
5737
+ declare const now: () => TypedExpression<Date>;
5402
5738
  /**
5403
- * Returns the current date without time.
5404
- * @returns A FunctionNode representing the CURRENT_DATE SQL function.
5739
+ * Returns the current date (without time).
5740
+ *
5741
+ * @returns A `TypedExpression<Date>` representing the `CURRENT_DATE` SQL function.
5405
5742
  */
5406
- declare const currentDate: () => FunctionNode;
5743
+ declare const currentDate: () => TypedExpression<Date>;
5407
5744
  /**
5408
- * Returns the current time without date.
5409
- * @returns A FunctionNode representing the CURRENT_TIME SQL function.
5745
+ * Returns the current time (without date).
5746
+ *
5747
+ * @returns A `TypedExpression<Date>` representing the `CURRENT_TIME` SQL function.
5410
5748
  */
5411
- declare const currentTime: () => FunctionNode;
5749
+ declare const currentTime: () => TypedExpression<Date>;
5412
5750
  /**
5413
5751
  * Returns the current UTC date and time.
5414
- * @returns A FunctionNode representing the UTC_NOW() SQL function.
5752
+ *
5753
+ * @returns A `TypedExpression<Date>` representing the `UTC_NOW()` SQL function.
5415
5754
  */
5416
- declare const utcNow: () => FunctionNode;
5755
+ declare const utcNow: () => TypedExpression<Date>;
5417
5756
  /**
5418
5757
  * Returns the current local time.
5419
- * @returns A FunctionNode representing the LOCALTIME SQL function.
5758
+ *
5759
+ * @returns A `TypedExpression<Date>` representing the `LOCALTIME` SQL function.
5420
5760
  */
5421
- declare const localTime: () => FunctionNode;
5761
+ declare const localTime: () => TypedExpression<Date>;
5422
5762
  /**
5423
5763
  * Returns the current local timestamp.
5424
- * @returns A FunctionNode representing the LOCALTIMESTAMP SQL function.
5764
+ *
5765
+ * @returns A `TypedExpression<Date>` representing the `LOCALTIMESTAMP` SQL function.
5425
5766
  */
5426
- declare const localTimestamp: () => FunctionNode;
5767
+ declare const localTimestamp: () => TypedExpression<Date>;
5427
5768
  /**
5428
5769
  * Extracts a specified part from a date or datetime value.
5429
- * @param part - The date part to extract (e.g., 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND').
5430
- * @param date - The date or datetime value to extract from.
5431
- * @returns A FunctionNode representing the EXTRACT SQL function.
5770
+ *
5771
+ * @param part - The date part to extract (e.g., 'YEAR', 'MONTH', 'DAY').
5772
+ * @param date - The date/datetime value or column.
5773
+ * @returns A `TypedExpression<number>` representing the `EXTRACT` SQL function.
5432
5774
  */
5433
- declare const extract: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
5775
+ declare const extract: (part: OperandInput$3, date: OperandInput$3) => TypedExpression<number>;
5434
5776
  /**
5435
5777
  * Extracts the year from a date or datetime value.
5436
- * @param date - The date or datetime value.
5437
- * @returns A FunctionNode representing the YEAR SQL function.
5778
+ *
5779
+ * @param date - The date value.
5780
+ * @returns A `TypedExpression<number>` representing the `YEAR` SQL function.
5438
5781
  */
5439
- declare const year: (date: OperandInput$3) => FunctionNode;
5782
+ declare const year: (date: OperandInput$3) => TypedExpression<number>;
5440
5783
  /**
5441
5784
  * Extracts the month from a date or datetime value.
5442
- * @param date - The date or datetime value.
5443
- * @returns A FunctionNode representing the MONTH SQL function.
5785
+ *
5786
+ * @param date - The date value.
5787
+ * @returns A `TypedExpression<number>` representing the `MONTH` SQL function.
5444
5788
  */
5445
- declare const month: (date: OperandInput$3) => FunctionNode;
5789
+ declare const month: (date: OperandInput$3) => TypedExpression<number>;
5446
5790
  /**
5447
5791
  * Extracts the day of the month from a date or datetime value.
5448
- * @param date - The date or datetime value.
5449
- * @returns A FunctionNode representing the DAY SQL function.
5792
+ *
5793
+ * @param date - The date value.
5794
+ * @returns A `TypedExpression<number>` representing the `DAY` SQL function.
5450
5795
  */
5451
- declare const day: (date: OperandInput$3) => FunctionNode;
5796
+ declare const day: (date: OperandInput$3) => TypedExpression<number>;
5452
5797
  /**
5453
5798
  * Adds a specified time interval to a date or datetime value.
5454
- * @param date - The date or datetime value to add to.
5455
- * @param interval - The number of units to add.
5456
- * @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
5457
- * @returns A FunctionNode representing the DATE_ADD SQL function.
5799
+ *
5800
+ * @param date - The base date.
5801
+ * @param interval - The numeric interval to add.
5802
+ * @param unit - The unit (e.g., 'DAY', 'MONTH').
5803
+ * @returns A `TypedExpression<Date>` representing the `DATE_ADD` SQL function.
5458
5804
  */
5459
- declare const dateAdd: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
5805
+ declare const dateAdd: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => TypedExpression<Date>;
5460
5806
  /**
5461
5807
  * Subtracts a specified time interval from a date or datetime value.
5462
- * @param date - The date or datetime value to subtract from.
5463
- * @param interval - The number of units to subtract.
5464
- * @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
5465
- * @returns A FunctionNode representing the DATE_SUB SQL function.
5808
+ *
5809
+ * @param date - The base date.
5810
+ * @param interval - The numeric interval to subtract.
5811
+ * @param unit - The unit (e.g., 'DAY', 'MONTH').
5812
+ * @returns A `TypedExpression<Date>` representing the `DATE_SUB` SQL function.
5466
5813
  */
5467
- declare const dateSub: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
5814
+ declare const dateSub: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => TypedExpression<Date>;
5468
5815
  /**
5469
5816
  * Returns the difference between two dates in days.
5470
- * @param date1 - The end date.
5471
- * @param date2 - The start date.
5472
- * @returns A FunctionNode representing the DATE_DIFF SQL function.
5817
+ *
5818
+ * @param date1 - End date.
5819
+ * @param date2 - Start date.
5820
+ * @returns A `TypedExpression<number>` representing the `DATE_DIFF` SQL function.
5473
5821
  */
5474
- declare const dateDiff: (date1: OperandInput$3, date2: OperandInput$3) => FunctionNode;
5822
+ declare const dateDiff: (date1: OperandInput$3, date2: OperandInput$3) => TypedExpression<number>;
5475
5823
  /**
5476
5824
  * Converts a date or datetime value to a formatted string.
5477
- * @param date - The date or datetime value to format.
5478
- * @param format - The format string (dialect-specific).
5479
- * @returns A FunctionNode representing the DATE_FORMAT SQL function.
5825
+ *
5826
+ * @param date - The date value.
5827
+ * @param format - Dialect-specific format string.
5828
+ * @returns A `TypedExpression<string>` representing the `DATE_FORMAT` SQL function.
5480
5829
  */
5481
- declare const dateFormat: (date: OperandInput$3, format: OperandInput$3) => FunctionNode;
5830
+ declare const dateFormat: (date: OperandInput$3, format: OperandInput$3) => TypedExpression<string>;
5482
5831
  /**
5483
- * Returns the current Unix timestamp (seconds since 1970-01-01 00:00:00 UTC).
5484
- * @returns A FunctionNode representing the UNIX_TIMESTAMP SQL function.
5832
+ * Returns the current Unix timestamp (seconds since epoch).
5833
+ *
5834
+ * @returns A `TypedExpression<number>` representing the `UNIX_TIMESTAMP` SQL function.
5485
5835
  */
5486
- declare const unixTimestamp: () => FunctionNode;
5836
+ declare const unixTimestamp: () => TypedExpression<number>;
5487
5837
  /**
5488
- * Converts a Unix timestamp (seconds since 1970-01-01 00:00:00 UTC) to a date.
5489
- * @param timestamp - Unix timestamp in seconds.
5490
- * @returns A FunctionNode representing the FROM_UNIXTIME SQL function.
5838
+ * Converts a Unix timestamp to a Date.
5839
+ *
5840
+ * @param timestamp - Seconds since epoch.
5841
+ * @returns A `TypedExpression<Date>` representing the `FROM_UNIXTIME` SQL function.
5491
5842
  */
5492
- declare const fromUnixTime: (timestamp: OperandInput$3) => FunctionNode;
5843
+ declare const fromUnixTime: (timestamp: OperandInput$3) => TypedExpression<Date>;
5493
5844
  /**
5494
5845
  * Returns the last day of the month for a given date.
5846
+ *
5495
5847
  * @param date - The date value.
5496
- * @returns A FunctionNode representing the END_OF_MONTH SQL function.
5848
+ * @returns A `TypedExpression<Date>` representing the `END_OF_MONTH` SQL function.
5497
5849
  */
5498
- declare const endOfMonth: (date: OperandInput$3) => FunctionNode;
5850
+ declare const endOfMonth: (date: OperandInput$3) => TypedExpression<Date>;
5499
5851
  /**
5500
5852
  * Returns the index of the weekday for a given date (1 = Sunday, 2 = Monday, etc.).
5853
+ *
5501
5854
  * @param date - The date value.
5502
- * @returns A FunctionNode representing the DAY_OF_WEEK SQL function.
5855
+ * @returns A `TypedExpression<number>` representing the `DAY_OF_WEEK` SQL function.
5503
5856
  */
5504
- declare const dayOfWeek: (date: OperandInput$3) => FunctionNode;
5857
+ declare const dayOfWeek: (date: OperandInput$3) => TypedExpression<number>;
5505
5858
  /**
5506
5859
  * Returns the week number of the year for a given date.
5860
+ *
5507
5861
  * @param date - The date value.
5508
- * @returns A FunctionNode representing the WEEK_OF_YEAR SQL function.
5862
+ * @returns A `TypedExpression<number>` representing the `WEEK_OF_YEAR` SQL function.
5509
5863
  */
5510
- declare const weekOfYear: (date: OperandInput$3) => FunctionNode;
5864
+ declare const weekOfYear: (date: OperandInput$3) => TypedExpression<number>;
5511
5865
  /**
5512
- * Truncates a date or datetime value to a specified precision (e.g., first day of the month/year).
5513
- * @param part - The truncation precision (e.g., 'YEAR', 'MONTH', 'DAY').
5514
- * @param date - The date or datetime value to truncate.
5515
- * @returns A FunctionNode representing the DATE_TRUNC SQL function.
5866
+ * Truncates a date or datetime value to a specified precision.
5867
+ *
5868
+ * @param part - The precision (e.g., 'YEAR', 'MONTH').
5869
+ * @param date - The date to truncate.
5870
+ * @returns A `TypedExpression<Date>` representing the `DATE_TRUNC` SQL function.
5516
5871
  */
5517
- declare const dateTrunc: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
5872
+ declare const dateTrunc: (part: OperandInput$3, date: OperandInput$3) => TypedExpression<Date>;
5518
5873
  /**
5519
- * Returns the difference between two timestamps as an interval.
5520
- * @param timestamp - The end timestamp.
5521
- * @param baseTimestamp - The start timestamp (optional, defaults to current time).
5522
- * @returns A FunctionNode representing the AGE SQL function.
5874
+ * Returns the difference between two timestamps as an interval string.
5875
+ *
5876
+ * @param timestamp - End timestamp.
5877
+ * @param baseTimestamp - Optional start timestamp.
5878
+ * @returns A `TypedExpression<string>` representing the `AGE` SQL function.
5523
5879
  */
5524
- declare const age: (timestamp: OperandInput$3, baseTimestamp?: OperandInput$3) => FunctionNode;
5880
+ declare const age: (timestamp: OperandInput$3, baseTimestamp?: OperandInput$3) => TypedExpression<string>;
5525
5881
  /**
5526
5882
  * Extracts the hour from a date or datetime value.
5527
- * @param date - The date or datetime value.
5528
- * @returns A FunctionNode representing the HOUR SQL function.
5883
+ *
5884
+ * @param date - The date value.
5885
+ * @returns A `TypedExpression<number>` representing the `HOUR` SQL function.
5529
5886
  */
5530
- declare const hour: (date: OperandInput$3) => FunctionNode;
5887
+ declare const hour: (date: OperandInput$3) => TypedExpression<number>;
5531
5888
  /**
5532
5889
  * Extracts the minute from a date or datetime value.
5533
- * @param date - The date or datetime value.
5534
- * @returns A FunctionNode representing the MINUTE SQL function.
5890
+ *
5891
+ * @param date - The date value.
5892
+ * @returns A `TypedExpression<number>` representing the `MINUTE` SQL function.
5535
5893
  */
5536
- declare const minute: (date: OperandInput$3) => FunctionNode;
5894
+ declare const minute: (date: OperandInput$3) => TypedExpression<number>;
5537
5895
  /**
5538
5896
  * Extracts the second from a date or datetime value.
5539
- * @param date - The date or datetime value.
5540
- * @returns A FunctionNode representing the SECOND SQL function.
5897
+ *
5898
+ * @param date - The date value.
5899
+ * @returns A `TypedExpression<number>` representing the `SECOND` SQL function.
5541
5900
  */
5542
- declare const second: (date: OperandInput$3) => FunctionNode;
5901
+ declare const second: (date: OperandInput$3) => TypedExpression<number>;
5543
5902
  /**
5544
5903
  * Extracts the quarter from a date or datetime value (1-4).
5545
- * @param date - The date or datetime value.
5546
- * @returns A FunctionNode representing the QUARTER SQL function.
5904
+ *
5905
+ * @param date - The date value.
5906
+ * @returns A `TypedExpression<number>` representing the `QUARTER` SQL function.
5547
5907
  */
5548
- declare const quarter: (date: OperandInput$3) => FunctionNode;
5908
+ declare const quarter: (date: OperandInput$3) => TypedExpression<number>;
5549
5909
 
5550
5910
  type OperandInput$2 = OperandNode | ColumnDef | string | number | boolean | null;
5551
5911
  /**
5552
5912
  * Returns the first non-null value in a list.
5553
- * @param args - The list of values to check.
5554
- * @returns A FunctionNode representing the COALESCE SQL function.
5913
+ *
5914
+ * @param args - The list of values or columns to check.
5915
+ * @returns A `TypedExpression<T>` representing the `COALESCE` SQL function.
5916
+ *
5917
+ * @example
5918
+ * coalesce(users.nickname, users.firstName, 'Guest');
5555
5919
  */
5556
- declare const coalesce: (...args: OperandInput$2[]) => FunctionNode;
5920
+ declare const coalesce: <T = any>(...args: OperandInput$2[]) => TypedExpression<T>;
5557
5921
  /**
5558
5922
  * Returns null if the two arguments are equal, otherwise returns the first argument.
5923
+ *
5559
5924
  * @param val1 - The first value.
5560
- * @param val2 - The second value.
5561
- * @returns A FunctionNode representing the NULLIF SQL function.
5925
+ * @param val2 - The second value to compare against.
5926
+ * @returns A `TypedExpression<T>` representing the `NULLIF` SQL function.
5562
5927
  */
5563
- declare const nullif: (val1: OperandInput$2, val2: OperandInput$2) => FunctionNode;
5928
+ declare const nullif: <T = any>(val1: OperandInput$2, val2: OperandInput$2) => TypedExpression<T>;
5564
5929
  /**
5565
5930
  * Returns the largest value in a list.
5566
- * @param args - The list of values to compare.
5567
- * @returns A FunctionNode representing the GREATEST SQL function.
5931
+ *
5932
+ * @param args - The list of values or columns to compare.
5933
+ * @returns A `TypedExpression<T>` representing the `GREATEST` SQL function.
5568
5934
  */
5569
- declare const greatest: (...args: OperandInput$2[]) => FunctionNode;
5935
+ declare const greatest: <T = any>(...args: OperandInput$2[]) => TypedExpression<T>;
5570
5936
  /**
5571
5937
  * Returns the smallest value in a list.
5572
- * @param args - The list of values to compare.
5573
- * @returns A FunctionNode representing the LEAST SQL function.
5938
+ *
5939
+ * @param args - The list of values or columns to compare.
5940
+ * @returns A `TypedExpression<T>` representing the `LEAST` SQL function.
5574
5941
  */
5575
- declare const least: (...args: OperandInput$2[]) => FunctionNode;
5942
+ declare const least: <T = any>(...args: OperandInput$2[]) => TypedExpression<T>;
5576
5943
  /**
5577
5944
  * Returns the first argument if it is not null, otherwise returns the second argument.
5945
+ *
5578
5946
  * @param val - The value to check.
5579
5947
  * @param defaultValue - The default value to return if val is null.
5580
- * @returns A FunctionNode representing the COALESCE SQL function.
5948
+ * @returns A `TypedExpression<T>` representing the `COALESCE` SQL function.
5581
5949
  */
5582
- declare const ifNull: (val: OperandInput$2, defaultValue: OperandInput$2) => FunctionNode;
5950
+ declare const ifNull: <T = any>(val: OperandInput$2, defaultValue: OperandInput$2) => TypedExpression<T>;
5583
5951
 
5584
5952
  type OperandInput$1 = OperandNode | ColumnDef | string | number | boolean | null;
5585
- declare const jsonLength: (target: OperandInput$1, path?: OperandInput$1) => FunctionNode;
5586
- declare const jsonSet: (target: OperandInput$1, path: OperandInput$1, value: OperandInput$1) => FunctionNode;
5587
- declare const jsonArrayAgg: (value: OperandInput$1) => FunctionNode;
5588
- declare const jsonContains: (target: OperandInput$1, candidate: OperandInput$1, path?: OperandInput$1) => FunctionNode;
5953
+ /**
5954
+ * Returns the number of elements in a JSON array or object.
5955
+ *
5956
+ * @param target - JSON column or value.
5957
+ * @param path - Optional JSON path.
5958
+ * @returns A `TypedExpression<number>` representing the `JSON_LENGTH` SQL function.
5959
+ */
5960
+ declare const jsonLength: (target: OperandInput$1, path?: OperandInput$1) => TypedExpression<number>;
5961
+ /**
5962
+ * Inserts or updates a value in a JSON document.
5963
+ *
5964
+ * @param target - JSON column or value.
5965
+ * @param path - JSON path to set.
5966
+ * @param value - Value to set.
5967
+ * @returns A `TypedExpression<any>` representing the `JSON_SET` SQL function.
5968
+ */
5969
+ declare const jsonSet: (target: OperandInput$1, path: OperandInput$1, value: OperandInput$1) => TypedExpression<any>;
5970
+ /**
5971
+ * Aggregates values into a JSON array.
5972
+ *
5973
+ * @param value - Column or expression to aggregate.
5974
+ * @returns A `TypedExpression<any[]>` representing the `JSON_ARRAYAGG` SQL function.
5975
+ */
5976
+ declare const jsonArrayAgg: (value: OperandInput$1) => TypedExpression<any[]>;
5977
+ /**
5978
+ * Checks if a JSON document contains a specific piece of data.
5979
+ *
5980
+ * @param target - JSON column or value.
5981
+ * @param candidate - Data to look for.
5982
+ * @param path - Optional JSON path to search within.
5983
+ * @returns A `TypedExpression<boolean>` representing the `JSON_CONTAINS` SQL function.
5984
+ */
5985
+ declare const jsonContains: (target: OperandInput$1, candidate: OperandInput$1, path?: OperandInput$1) => TypedExpression<boolean>;
5589
5986
 
5590
5987
  type OperandInput = OperandNode | ColumnDef | string | number | boolean | null;
5591
- declare const arrayAppend: (array: OperandInput, value: OperandInput) => FunctionNode;
5988
+ /**
5989
+ * Appends a value to the end of an array.
5990
+ *
5991
+ * @param array - Array column or value.
5992
+ * @param value - Value to append.
5993
+ * @returns A `TypedExpression<any[]>` representing the `ARRAY_APPEND` SQL function.
5994
+ */
5995
+ declare const arrayAppend: (array: OperandInput, value: OperandInput) => TypedExpression<any[]>;
5592
5996
 
5593
5997
  /**
5594
5998
  * Browser-compatible implementation of AsyncLocalStorage.
@@ -6095,6 +6499,14 @@ declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undef
6095
6499
  * @returns Promise resolving to array of entity instances
6096
6500
  */
6097
6501
  declare function executeHydrated<TTable extends TableDef>(session: OrmSession, qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable>[]>;
6502
+ /**
6503
+ * Executes a hydrated query and returns plain row objects (no entity proxies).
6504
+ * @template TTable - The table type
6505
+ * @param session - The ORM session
6506
+ * @param qb - The select query builder
6507
+ * @returns Promise resolving to array of plain row objects
6508
+ */
6509
+ declare function executeHydratedPlain<TTable extends TableDef>(session: OrmSession, qb: SelectQueryBuilder<unknown, TTable>): Promise<Record<string, unknown>[]>;
6098
6510
  /**
6099
6511
  * Executes a hydrated query using execution and hydration contexts.
6100
6512
  * @template TTable - The table type
@@ -6104,6 +6516,14 @@ declare function executeHydrated<TTable extends TableDef>(session: OrmSession, q
6104
6516
  * @returns Promise resolving to array of entity instances
6105
6517
  */
6106
6518
  declare function executeHydratedWithContexts<TTable extends TableDef>(execCtx: ExecutionContext, hydCtx: HydrationContext, qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable>[]>;
6519
+ /**
6520
+ * Executes a hydrated query using execution context and returns plain row objects.
6521
+ * @template TTable - The table type
6522
+ * @param execCtx - The execution context
6523
+ * @param qb - The select query builder
6524
+ * @returns Promise resolving to array of plain row objects
6525
+ */
6526
+ declare function executeHydratedPlainWithContexts<TTable extends TableDef>(execCtx: ExecutionContext, qb: SelectQueryBuilder<unknown, TTable>): Promise<Record<string, unknown>[]>;
6107
6527
 
6108
6528
  type JsonifyScalar<T> = T extends Date ? string : T;
6109
6529
  /**
@@ -6253,7 +6673,8 @@ type EntityTable<TEntity extends object> = Omit<TableDef<{
6253
6673
  [K in RelationKeys<TEntity>]: NonNullable<TEntity[K]> extends HasManyCollection<infer TChild> ? HasManyRelation<EntityTable<NonNullable<TChild> & object>> : NonNullable<TEntity[K]> extends ManyToManyCollection<infer TTarget, infer TPivot> ? BelongsToManyRelation<EntityTable<NonNullable<TTarget> & object>, TPivot extends object ? EntityTable<NonNullable<TPivot> & object> : TableDef> : NonNullable<TEntity[K]> extends HasOneReference<infer TChild> ? HasOneRelation<EntityTable<NonNullable<TChild> & object>> : NonNullable<TEntity[K]> extends BelongsToReference<infer TParent> ? BelongsToRelation<EntityTable<NonNullable<TParent> & object>> : NonNullable<TEntity[K]> extends object ? BelongsToRelation<EntityTable<NonNullable<TEntity[K]> & object>> : never;
6254
6674
  };
6255
6675
  };
6256
- declare const selectFromEntity: <TEntity extends object>(ctor: EntityConstructor<TEntity>) => SelectQueryBuilder<TEntity, EntityTable<TEntity>>;
6676
+ type DecoratedEntityInstance<TEntity extends object> = TEntity & EntityInstance<EntityTable<TEntity>>;
6677
+ declare const selectFromEntity: <TEntity extends object>(ctor: EntityConstructor<TEntity>) => SelectQueryBuilder<DecoratedEntityInstance<TEntity>, EntityTable<TEntity>>;
6257
6678
  /**
6258
6679
  * Public API: opt-in ergonomic entity reference (decorator-level).
6259
6680
  *
@@ -6350,6 +6771,7 @@ declare class DefaultEntityMaterializer implements EntityMaterializer {
6350
6771
  * Simple heuristic to check if an object looks like an entity.
6351
6772
  */
6352
6773
  private isEntityLike;
6774
+ private materializeEntityProxy;
6353
6775
  }
6354
6776
  /**
6355
6777
  * Convenience function to materialize query results as real class instances.
@@ -6524,4 +6946,4 @@ type PooledExecutorFactoryOptions<TConn> = {
6524
6946
  */
6525
6947
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
6526
6948
 
6527
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
6949
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };