orchid-orm 1.6.1 → 1.6.2

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
@@ -146,12 +146,31 @@ declare type Table = {
146
146
  };
147
147
  declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
148
148
  columnTypes?: CT | ((t: DefaultColumnTypes) => CT) | undefined;
149
+ snakeCase?: boolean | undefined;
149
150
  }) => {
150
151
  new (): {
151
152
  table: string;
152
153
  columns: TableConfig;
153
154
  schema?: string | undefined;
154
155
  columnTypes: ColumnTypesBase extends CT ? {
156
+ timestamps: <T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
157
+ name(name: string): {
158
+ timestamp(): T;
159
+ };
160
+ timestamp(): T;
161
+ }) => {
162
+ createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
163
+ updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
164
+ };
165
+ timestampsSnakeCase: <T_1 extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
166
+ name(name: string): {
167
+ timestamp(): T_1;
168
+ };
169
+ timestamp(): T_1;
170
+ }) => {
171
+ createdAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
172
+ updatedAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
173
+ };
155
174
  name: typeof orchid_core.name;
156
175
  raw: (sql: string, values?: false | Record<string, unknown> | undefined) => orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>;
157
176
  smallint(this: ColumnTypesBase): pqb.SmallIntColumn;
@@ -177,7 +196,7 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
177
196
  timeWithTimeZone<Precision_5 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_5 | undefined): pqb.TimeWithTimeZoneColumn<Precision_5>;
178
197
  interval<Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(this: ColumnTypesBase, fields?: Fields | undefined, precision?: Precision_6 | undefined): pqb.IntervalColumn<Fields, Precision_6>;
179
198
  boolean(this: ColumnTypesBase): pqb.BooleanColumn;
180
- enum<U extends string, T extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T): pqb.EnumColumn<U, T>;
199
+ enum<U extends string, T_2 extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T_2): pqb.EnumColumn<U, T_2>;
181
200
  point(this: ColumnTypesBase): pqb.PointColumn;
182
201
  line(this: ColumnTypesBase): pqb.LineColumn;
183
202
  lseg(this: ColumnTypesBase): pqb.LsegColumn;
@@ -197,8 +216,8 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
197
216
  xml(this: ColumnTypesBase): pqb.XMLColumn;
198
217
  json<Type extends orchid_core.JSONTypeAny>(this: ColumnTypesBase, schemaOrFn: Type | ((j: {
199
218
  set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
200
- tuple: <T_1 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => orchid_core.JSONTuple<T_1, Rest>;
201
- union: <T_2 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_2) => orchid_core.JSONUnion<T_2>;
219
+ tuple: <T_3 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_3, rest?: Rest) => orchid_core.JSONTuple<T_3, Rest>;
220
+ union: <T_4 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_4) => orchid_core.JSONUnion<T_4>;
202
221
  any: () => orchid_core.JSONAny;
203
222
  bigint: () => orchid_core.JSONBigInt;
204
223
  boolean: () => orchid_core.JSONBoolean;
@@ -213,31 +232,25 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
213
232
  void: () => orchid_core.JSONVoid;
214
233
  array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
215
234
  discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
216
- enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => orchid_core.JSONEnum<U_1, T_3>;
217
- instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => orchid_core.JSONInstanceOf<T_4>;
235
+ enum: <U_1 extends string, T_5 extends [U_1, ...U_1[]]>(options: T_5) => orchid_core.JSONEnum<U_1, T_5>;
236
+ instanceOf: <T_6 extends new (...args: any[]) => any>(cls: T_6) => orchid_core.JSONInstanceOf<T_6>;
218
237
  intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
219
- lazy: <T_5 extends orchid_core.JSONTypeAny>(fn: () => T_5) => orchid_core.JSONLazy<T_5>;
220
- literal: <T_6 extends orchid_core.Primitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
238
+ lazy: <T_7 extends orchid_core.JSONTypeAny>(fn: () => T_7) => orchid_core.JSONLazy<T_7>;
239
+ literal: <T_8 extends orchid_core.Primitive>(value: T_8) => orchid_core.JSONLiteral<T_8>;
221
240
  map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
222
- nativeEnum: <T_7 extends orchid_core.EnumLike>(givenEnum: T_7) => orchid_core.JSONNativeEnum<T_7>;
223
- nullable: <T_8 extends orchid_core.JSONTypeAny>(type: T_8) => orchid_core.JSONNullable<T_8>;
224
- nullish: <T_9 extends orchid_core.JSONTypeAny>(type: T_9) => orchid_core.JSONNullish<T_9>;
225
- object: <T_10 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_10) => orchid_core.JSONObject<T_10, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
241
+ nativeEnum: <T_9 extends orchid_core.EnumLike>(givenEnum: T_9) => orchid_core.JSONNativeEnum<T_9>;
242
+ nullable: <T_10 extends orchid_core.JSONTypeAny>(type: T_10) => orchid_core.JSONNullable<T_10>;
243
+ nullish: <T_11 extends orchid_core.JSONTypeAny>(type: T_11) => orchid_core.JSONNullish<T_11>;
244
+ object: <T_12 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_12) => orchid_core.JSONObject<T_12, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never) & {
226
245
  [k: string]: Catchall["type"];
227
- } extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
246
+ } extends infer T_14 extends object ? { [k_2 in keyof T_14]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never) & {
228
247
  [k: string]: Catchall["type"];
229
248
  })[k_2]; } : never>;
230
- optional: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONOptional<T_13>;
249
+ optional: <T_15 extends orchid_core.JSONTypeAny>(type: T_15) => orchid_core.JSONOptional<T_15>;
231
250
  record: typeof orchid_core.record;
232
251
  }) => Type)): pqb.JSONColumn<Type>;
233
252
  jsonText(this: ColumnTypesBase): pqb.JSONTextColumn;
234
253
  array<Item extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: ColumnTypesBase, item: Item): pqb.ArrayColumn<Item>;
235
- timestamps: <T_14 extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: {
236
- timestamp(): T_14;
237
- }) => {
238
- createdAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
239
- updatedAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
240
- };
241
254
  primaryKey(columns: string[], options?: {
242
255
  name?: string | undefined;
243
256
  } | undefined): {};
@@ -249,7 +262,25 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
249
262
  };
250
263
  } : CT;
251
264
  noPrimaryKey?: boolean | undefined;
252
- setColumns: <T_15 extends ColumnsShape>(fn: (t: ColumnTypesBase extends CT ? {
265
+ setColumns: <T_16 extends ColumnsShape>(fn: (t: ColumnTypesBase extends CT ? {
266
+ timestamps: <T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
267
+ name(name: string): {
268
+ timestamp(): T;
269
+ };
270
+ timestamp(): T;
271
+ }) => {
272
+ createdAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
273
+ updatedAt: orchid_core.ColumnWithDefault<T, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
274
+ };
275
+ timestampsSnakeCase: <T_1 extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
276
+ name(name: string): {
277
+ timestamp(): T_1;
278
+ };
279
+ timestamp(): T_1;
280
+ }) => {
281
+ createdAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
282
+ updatedAt: orchid_core.ColumnWithDefault<T_1, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
283
+ };
253
284
  name: typeof orchid_core.name;
254
285
  raw: (sql: string, values?: false | Record<string, unknown> | undefined) => orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>;
255
286
  smallint(this: ColumnTypesBase): pqb.SmallIntColumn;
@@ -275,7 +306,7 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
275
306
  timeWithTimeZone<Precision_5 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_5 | undefined): pqb.TimeWithTimeZoneColumn<Precision_5>;
276
307
  interval<Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(this: ColumnTypesBase, fields?: Fields | undefined, precision?: Precision_6 | undefined): pqb.IntervalColumn<Fields, Precision_6>;
277
308
  boolean(this: ColumnTypesBase): pqb.BooleanColumn;
278
- enum<U extends string, T extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T): pqb.EnumColumn<U, T>;
309
+ enum<U extends string, T_2 extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T_2): pqb.EnumColumn<U, T_2>;
279
310
  point(this: ColumnTypesBase): pqb.PointColumn;
280
311
  line(this: ColumnTypesBase): pqb.LineColumn;
281
312
  lseg(this: ColumnTypesBase): pqb.LsegColumn;
@@ -295,8 +326,8 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
295
326
  xml(this: ColumnTypesBase): pqb.XMLColumn;
296
327
  json<Type extends orchid_core.JSONTypeAny>(this: ColumnTypesBase, schemaOrFn: Type | ((j: {
297
328
  set: <Value extends orchid_core.JSONTypeAny>(valueType: Value) => orchid_core.JSONSet<Value>;
298
- tuple: <T_1 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => orchid_core.JSONTuple<T_1, Rest>;
299
- union: <T_2 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_2) => orchid_core.JSONUnion<T_2>;
329
+ tuple: <T_3 extends [] | orchid_core.JSONTupleItems, Rest extends orchid_core.JSONTypeAny | null = null>(items: T_3, rest?: Rest) => orchid_core.JSONTuple<T_3, Rest>;
330
+ union: <T_4 extends [orchid_core.JSONTypeAny, orchid_core.JSONTypeAny, ...orchid_core.JSONTypeAny[]]>(types: T_4) => orchid_core.JSONUnion<T_4>;
300
331
  any: () => orchid_core.JSONAny;
301
332
  bigint: () => orchid_core.JSONBigInt;
302
333
  boolean: () => orchid_core.JSONBoolean;
@@ -311,31 +342,25 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
311
342
  void: () => orchid_core.JSONVoid;
312
343
  array: <Type_1 extends orchid_core.JSONTypeAny>(element: Type_1) => orchid_core.JSONArray<Type_1, "many">;
313
344
  discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends orchid_core.Primitive, Types extends [orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...orchid_core.JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => orchid_core.JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
314
- enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => orchid_core.JSONEnum<U_1, T_3>;
315
- instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => orchid_core.JSONInstanceOf<T_4>;
345
+ enum: <U_1 extends string, T_5 extends [U_1, ...U_1[]]>(options: T_5) => orchid_core.JSONEnum<U_1, T_5>;
346
+ instanceOf: <T_6 extends new (...args: any[]) => any>(cls: T_6) => orchid_core.JSONInstanceOf<T_6>;
316
347
  intersection: <Left extends orchid_core.JSONTypeAny, Right extends orchid_core.JSONTypeAny>(left: Left, right: Right) => orchid_core.JSONIntersection<Left, Right>;
317
- lazy: <T_5 extends orchid_core.JSONTypeAny>(fn: () => T_5) => orchid_core.JSONLazy<T_5>;
318
- literal: <T_6 extends orchid_core.Primitive>(value: T_6) => orchid_core.JSONLiteral<T_6>;
348
+ lazy: <T_7 extends orchid_core.JSONTypeAny>(fn: () => T_7) => orchid_core.JSONLazy<T_7>;
349
+ literal: <T_8 extends orchid_core.Primitive>(value: T_8) => orchid_core.JSONLiteral<T_8>;
319
350
  map: <Key extends orchid_core.JSONTypeAny, Value_1 extends orchid_core.JSONTypeAny>(keyType: Key, valueType: Value_1) => orchid_core.JSONMap<Key, Value_1>;
320
- nativeEnum: <T_7 extends orchid_core.EnumLike>(givenEnum: T_7) => orchid_core.JSONNativeEnum<T_7>;
321
- nullable: <T_8 extends orchid_core.JSONTypeAny>(type: T_8) => orchid_core.JSONNullable<T_8>;
322
- nullish: <T_9 extends orchid_core.JSONTypeAny>(type: T_9) => orchid_core.JSONNullish<T_9>;
323
- object: <T_10 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_10) => orchid_core.JSONObject<T_10, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
351
+ nativeEnum: <T_9 extends orchid_core.EnumLike>(givenEnum: T_9) => orchid_core.JSONNativeEnum<T_9>;
352
+ nullable: <T_10 extends orchid_core.JSONTypeAny>(type: T_10) => orchid_core.JSONNullable<T_10>;
353
+ nullish: <T_11 extends orchid_core.JSONTypeAny>(type: T_11) => orchid_core.JSONNullish<T_11>;
354
+ object: <T_12 extends orchid_core.JSONObjectShape, UnknownKeys extends orchid_core.UnknownKeysParam = "strip", Catchall extends orchid_core.JSONTypeAny = orchid_core.JSONTypeAny>(shape: T_12) => orchid_core.JSONObject<T_12, UnknownKeys, Catchall, orchid_core.JSONTypeAny extends Catchall ? orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never : (orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never) & {
324
355
  [k: string]: Catchall["type"];
325
- } extends infer T_12 extends object ? { [k_2 in keyof T_12]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 extends object ? { [k in keyof T_11]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
356
+ } extends infer T_14 extends object ? { [k_2 in keyof T_14]: ((orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }> extends infer T_13 extends object ? { [k in keyof T_13]: orchid_core.addQuestionMarks<{ [k_1 in keyof T_12]: T_12[k_1]["type"]; }>[k]; } : never) & {
326
357
  [k: string]: Catchall["type"];
327
358
  })[k_2]; } : never>;
328
- optional: <T_13 extends orchid_core.JSONTypeAny>(type: T_13) => orchid_core.JSONOptional<T_13>;
359
+ optional: <T_15 extends orchid_core.JSONTypeAny>(type: T_15) => orchid_core.JSONOptional<T_15>;
329
360
  record: typeof orchid_core.record;
330
361
  }) => Type)): pqb.JSONColumn<Type>;
331
362
  jsonText(this: ColumnTypesBase): pqb.JSONTextColumn;
332
363
  array<Item extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: ColumnTypesBase, item: Item): pqb.ArrayColumn<Item>;
333
- timestamps: <T_14 extends pqb.ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: {
334
- timestamp(): T_14;
335
- }) => {
336
- createdAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
337
- updatedAt: orchid_core.ColumnWithDefault<T_14, orchid_core.RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>>;
338
- };
339
364
  primaryKey(columns: string[], options?: {
340
365
  name?: string | undefined;
341
366
  } | undefined): {};
@@ -345,9 +370,9 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
345
370
  <Table_1 extends pqb.ForeignKeyTableWithColumns, Columns extends [Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>, ...Exclude<keyof InstanceType<Table_1>["columns"]["shape"], number | symbol>[]]>(columns: string[], fn: () => Table_1, foreignColumns: Columns, options?: pqb.ForeignKeyOptions | undefined): {};
346
371
  <Table_2 extends string, Columns_1 extends [string, ...string[]]>(columns: string[], table: Table_2, foreignColumns: Columns_1, options?: pqb.ForeignKeyOptions | undefined): {};
347
372
  };
348
- } : CT) => T_15) => {
349
- shape: T_15;
350
- type: ColumnShapeOutput<T_15>;
373
+ } : CT) => T_16) => {
374
+ shape: T_16;
375
+ type: ColumnShapeOutput<T_16>;
351
376
  };
352
377
  belongsTo<Self extends any, Related extends TableClass<Table>, Scope extends Query, Options extends {
353
378
  primaryKey: keyof InstanceType<Related>["columns"]["shape"];
package/dist/index.js CHANGED
@@ -34,7 +34,10 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
34
34
  var typescript__default = /*#__PURE__*/_interopDefaultLegacy(typescript);
35
35
 
36
36
  const createBaseTable = (options = { columnTypes: pqb.columnTypes }) => {
37
- const ct = typeof options.columnTypes === "function" ? options.columnTypes(pqb.columnTypes) : options.columnTypes;
37
+ const ct = typeof options.columnTypes === "function" ? options.columnTypes(pqb.columnTypes) : options.columnTypes || pqb.columnTypes;
38
+ if (options.snakeCase) {
39
+ ct[orchidCore.snakeCaseKey] = true;
40
+ }
38
41
  return create(ct);
39
42
  };
40
43
  const create = (columnTypes2) => {
@@ -1235,8 +1238,11 @@ const makeRelationQuery = (table, definedAs, relationName, data) => {
1235
1238
  toTable._take();
1236
1239
  }
1237
1240
  const query = this.isSubQuery ? toTable : toTable._whereExists(
1238
- this.baseQuery,
1239
- (q) => data.reverseJoin(this, toTable)
1241
+ this,
1242
+ (q) => data.reverseJoin(
1243
+ q,
1244
+ toTable
1245
+ )
1240
1246
  );
1241
1247
  query.query[pqb.relationQueryKey] = {
1242
1248
  relationName,