forj 0.1.5 → 0.1.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "forj",
3
3
  "description": "SQLite ORM and Query Builder whitout dependencies",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "files": ["src"],
@@ -33,17 +33,17 @@
33
33
  "@aws-sdk/lib-dynamodb": "3.817.0",
34
34
  "pluralize": "^8.0",
35
35
  "t0n": "^0.1",
36
- "zod": "^3.19.1"
36
+ "zod": "^4.3.6"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/pluralize": "^0.0.33",
40
40
  "@cloudflare/workers-types": "^4.20260113.0",
41
- "bun-types": "^1.2.13",
41
+ "bun-types": "^1.3.8",
42
42
  "terser": "^5.46.0",
43
43
  "tiny-glob": "^0.2",
44
44
  "tsup": "^8.5.1",
45
45
  "tsx": "^4.19.4",
46
- "typescript": "^5.8.3"
46
+ "typescript": "^5.9.3"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=18.0.0"
@@ -89,4 +89,4 @@
89
89
  "bun",
90
90
  "nodejs"
91
91
  ]
92
- }
92
+ }
@@ -39,7 +39,7 @@ export default class ClauseBuilder<
39
39
  this.#schema = schema
40
40
  }
41
41
 
42
- #nested(fn: WhereFn<T, C>, operator: ClauseOperator = 'AND') {
42
+ #nested(fn: WhereFn<T>, operator: ClauseOperator = 'AND') {
43
43
  const nested = new ClauseBuilder<T, C>(this.#table, this.#schema)
44
44
  fn(nested)
45
45
 
@@ -79,9 +79,8 @@ export default class ClauseBuilder<
79
79
  // @ts-ignore
80
80
  column = parseColumn(String(column), this.#table)
81
81
 
82
- if (this.#schema && !zSame(column, value, this.#schema)) {
83
- throw new Error(`Table column '${String(column)}' of type '${zType(column, this.#schema)}' is not assignable as type of '${typeof value}'.`)
84
- }
82
+ if (this.#schema && !zSame(column.replace(/"/g, ''), value, this.#schema))
83
+ throw new Error(`Table column '${String(column.replace(/"/g, ''))}' of type '${zType(column.replace(/"/g, ''), this.#schema)}' is not assignable as type of '${typeof value}'.`)
85
84
 
86
85
  return isJoinCompare(value, this.#schema) // @ts-ignore
87
86
  ? this.#clause(`${column} ${operator} ${value}`, [], logical) // @ts-ignore
@@ -112,31 +111,31 @@ export default class ClauseBuilder<
112
111
  return this.#clause(parseColumn(column, this.#table) + ` ${operator} (${values.map(() => '?').join(', ')})`, values, logical)
113
112
  }
114
113
 
115
- whereIn(column: C, values: T[C][]) { // @ts-ignore
114
+ whereIn<K extends keyof T>(column: K, values: T[K][]) { // @ts-ignore
116
115
  return this.#in(column, values, 'IN')
117
116
  }
118
- in(column: C, values: T[C][]) {
117
+ in<K extends keyof T>(column: K, values: T[K][]) {
119
118
  return this.whereIn(column, values)
120
119
  }
121
120
 
122
- whereNotIn(column: C, values: T[C][]) { // @ts-ignore
121
+ whereNotIn<K extends keyof T>(column: K, values: T[K][]) { // @ts-ignore
123
122
  return this.#in(column, values, 'NOT IN')
124
123
  }
125
- notIn(column: C, values: T[C][]) {
124
+ notIn<K extends keyof T>(column: K, values: T[K][]) {
126
125
  return this.whereNotIn(column, values)
127
126
  }
128
127
 
129
- orWhereIn(column: C, values: T[C][]) { // @ts-ignore
128
+ orWhereIn<K extends keyof T>(column: K, values: T[K][]) { // @ts-ignore
130
129
  return this.#in(column, values, 'IN', 'OR')
131
130
  }
132
- orIn(column: C, values: T[C][]) {
131
+ orIn<K extends keyof T>(column: K, values: T[K][]) {
133
132
  return this.orWhereIn(column, values)
134
133
  }
135
134
 
136
- orWhereNotIn(column: C, values: T[C][]) { // @ts-ignore
135
+ orWhereNotIn<K extends keyof T>(column: K, values: T[K][]) { // @ts-ignore
137
136
  return this.#in(column, values, 'NOT IN', 'OR')
138
137
  }
139
- orNotIn(column: C, values: T[C][]) {
138
+ orNotIn<K extends keyof T>(column: K, values: T[K][]) {
140
139
  return this.orWhereNotIn(column, values)
141
140
  }
142
141
 
@@ -150,31 +149,31 @@ export default class ClauseBuilder<
150
149
  return this.#clause(parseColumn(column, this.#table) + ` ${operator} ? AND ?`, [one, two], logical)
151
150
  }
152
151
 
153
- whereBetween(column: C, one: T[C], two: T[C]) { // @ts-ignore
152
+ whereBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) { // @ts-ignore
154
153
  return this.#between(column, one, two, 'BETWEEN')
155
154
  }
156
- between(column: C, one: T[C], two: T[C]) {
155
+ between<K extends keyof T>(column: K, one: T[K], two: T[K]) {
157
156
  return this.whereBetween(column, one, two)
158
157
  }
159
158
 
160
- orWhereBetween(column: C, one: T[C], two: T[C]) { // @ts-ignore
159
+ orWhereBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) { // @ts-ignore
161
160
  return this.#between(column, one, two, 'BETWEEN', 'OR')
162
161
  }
163
- orBetween(column: C, one: T[C], two: T[C]) {
162
+ orBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) {
164
163
  return this.orWhereBetween(column, one, two)
165
164
  }
166
165
 
167
- whereNotBetween(column: C, one: T[C], two: T[C]) { // @ts-ignore
166
+ whereNotBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) { // @ts-ignore
168
167
  return this.#between(column, one, two, 'NOT BETWEEN')
169
168
  }
170
- notBetween(column: C, one: T[C], two: T[C]) {
169
+ notBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) {
171
170
  return this.whereNotBetween(column, one, two)
172
171
  }
173
172
 
174
- orWhereNotBetween(column: C, one: T[C], two: T[C]) { // @ts-ignore
173
+ orWhereNotBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) { // @ts-ignore
175
174
  return this.#between(column, one, two, 'NOT BETWEEN', 'OR')
176
175
  }
177
- orNotBetween(column: C, one: T[C], two: T[C]) {
176
+ orNotBetween<K extends keyof T>(column: K, one: T[K], two: T[K]) {
178
177
  return this.orWhereNotBetween(column, one, two)
179
178
  }
180
179
 
@@ -186,31 +185,31 @@ export default class ClauseBuilder<
186
185
  return this.#clause(parseColumn(column, this.#table) +` ${operator} NULL`, [], logical)
187
186
  }
188
187
 
189
- whereNull(column: C) {
188
+ whereNull<K extends keyof T>(column: K) {
190
189
  return this.#null(column as string)
191
190
  }
192
- onNull(column: C) {
191
+ onNull<K extends keyof T>(column: K) {
193
192
  return this.whereNull(column)
194
193
  }
195
194
 
196
- orWhereNull(column: C) {
195
+ orWhereNull<K extends keyof T>(column: K) {
197
196
  return this.#null(column as string, 'IS', 'OR')
198
197
  }
199
- orOnNull(column: C) {
198
+ orOnNull<K extends keyof T>(column: K) {
200
199
  return this.orWhereNull(column)
201
200
  }
202
201
 
203
- whereNotNull(column: C) {
202
+ whereNotNull<K extends keyof T>(column: K) {
204
203
  return this.#null(column as string, 'IS NOT')
205
204
  }
206
- onNotNull(column: C) {
205
+ onNotNull<K extends keyof T>(column: K) {
207
206
  return this.whereNotNull(column)
208
207
  }
209
208
 
210
- orWhereNotNull(column: C) {
209
+ orWhereNotNull<K extends keyof T>(column: K) {
211
210
  return this.#null(column as string, 'IS NOT', 'OR')
212
211
  }
213
- orNotNull(column: C) {
212
+ orNotNull<K extends keyof T>(column: K) {
214
213
  return this.orWhereNotNull(column)
215
214
  }
216
215
  }
package/src/d1/model.ts CHANGED
@@ -10,16 +10,16 @@ import { Envir } from 't0n'
10
10
  import QueryBuilder from '../query-builder'
11
11
  import BModel from '../model'
12
12
  import type {
13
- DBSchema, SchemaKeys,
13
+ DBSchema,
14
14
  Item,
15
15
  Pipe, Result, RunFn,
16
16
  } from '../types'
17
17
 
18
18
  export function Model<
19
19
  TSchema extends DBSchema,
20
- TBase extends SchemaKeys<TSchema>
20
+ TBase extends keyof z.infer<TSchema>
21
21
  >(schema: TSchema, base: TBase) {
22
- type S = z.infer<typeof schema>
22
+ type S = z.infer<TSchema>
23
23
  return class extends BaseModel<TBase, S> {
24
24
  static $table = String(base)
25
25
  static $schema = schema
@@ -55,8 +55,9 @@ export abstract class BaseModel<TB extends keyof DB, DB> extends BModel<TB, DB>
55
55
  ): Promise<Result<T, C>> => {
56
56
  let stmt = db.prepare(qb.query)
57
57
 
58
- if (qb.args?.length)
59
- stmt = stmt.bind(...qb.args)
58
+ const args = qb.args
59
+ if (args?.length)
60
+ stmt = stmt.bind(...args)
60
61
 
61
62
  const resp = await stmt.run<Item<T, C>>()
62
63
 
@@ -12,17 +12,26 @@ export function arraySchema(v: any): any {
12
12
  return v
13
13
  }
14
14
 
15
+ function getArrayItem(schema: z.ZodArray<any>): ZodTypeAny {
16
+ const def: any = schema._def
17
+ return (def.element ?? def.type ?? def.innerType) as ZodTypeAny
18
+ }
19
+
15
20
  export function extractZodKeys(schema: ZodTypeAny): SchemaStructure {
16
21
  if (schema instanceof z.ZodObject) {
17
- return Object.entries(schema.shape).map(([key, value]) => {
22
+ const shape = schema.shape
23
+
24
+ return Object.entries(shape).map(([key, value]) => {
18
25
  const inner = unwrap(value as ZodTypeAny)
19
26
 
20
27
  if (inner instanceof z.ZodObject)
21
28
  return notEmpty(key, extractZodKeys(inner))
22
29
 
23
30
  if (inner instanceof z.ZodArray) {
24
- const item = unwrap(inner._def.type as ZodTypeAny)
25
- return item instanceof z.ZodObject ? notEmpty(key, extractZodKeys(item)) : key
31
+ const item = unwrap(getArrayItem(inner))
32
+ return item instanceof z.ZodObject
33
+ ? notEmpty(key, extractZodKeys(item))
34
+ : key
26
35
  }
27
36
 
28
37
  return key
@@ -30,7 +39,8 @@ export function extractZodKeys(schema: ZodTypeAny): SchemaStructure {
30
39
  }
31
40
 
32
41
  if (schema instanceof z.ZodArray) {
33
- const item = unwrap(schema._def.type as ZodTypeAny)
42
+ const item = unwrap(getArrayItem(schema))
43
+
34
44
  if (item instanceof z.ZodObject)
35
45
  return arraySchema(extractZodKeys(item))
36
46
 
@@ -41,23 +51,41 @@ export function extractZodKeys(schema: ZodTypeAny): SchemaStructure {
41
51
  }
42
52
 
43
53
  export function unwrap(schema: ZodTypeAny): ZodTypeAny {
44
- if (schema instanceof z.ZodOptional || schema instanceof z.ZodNullable)
45
- return unwrap(schema._def.innerType)
54
+ while (true) {
55
+ if (schema instanceof z.ZodOptional || schema instanceof z.ZodNullable) {
56
+ schema = (schema._def as any).innerType
57
+ continue
58
+ }
46
59
 
47
- if (schema instanceof z.ZodDefault)
48
- return unwrap(schema._def.innerType)
60
+ if (schema instanceof z.ZodDefault) {
61
+ schema = (schema._def as any).innerType
62
+ continue
63
+ }
49
64
 
50
- // if (schema instanceof z.ZodUnion)
51
- // return unwrap(schema._def.options[0] as ZodTypeAny)
65
+ if (schema instanceof z.ZodUnion) {
66
+ const options = (schema._def as any).options as ZodTypeAny[]
67
+ const nonEmpty = options.find(
68
+ opt => !(opt instanceof z.ZodUndefined) && !(opt instanceof z.ZodNull)
69
+ )
70
+ schema = nonEmpty ?? options[0]
71
+ continue
72
+ }
52
73
 
53
- if (schema instanceof z.ZodUnion) {
54
- const options = schema._def.options as ZodTypeAny[]
55
- const nonEmptyOption = options.find(opt => !(opt instanceof z.ZodUndefined) && !(opt instanceof z.ZodNull))
56
- return nonEmptyOption ? unwrap(nonEmptyOption) : options[0]
57
- }
74
+ const def: any = schema._def
75
+
76
+ // unwrap transforms / pipes do v4
77
+ if (def?.schema) {
78
+ schema = def.schema
79
+ continue
80
+ }
58
81
 
59
- if (schema instanceof z.ZodEffects)
60
- return unwrap(schema._def.schema)
82
+ if (def?.innerType) {
83
+ schema = def.innerType
84
+ continue
85
+ }
86
+
87
+ break
88
+ }
61
89
 
62
90
  return schema
63
91
  }
package/src/model.ts CHANGED
@@ -4,6 +4,8 @@ import type {
4
4
  Operator, OrderDirection,
5
5
  WhereFn, WhereArgs,
6
6
  DBSchema, Pipe,
7
+ Value,
8
+ JoinArgs,
7
9
  } from './types'
8
10
 
9
11
  export default abstract class Model<TB extends keyof DB, DB> {
@@ -14,6 +16,10 @@ export default abstract class Model<TB extends keyof DB, DB> {
14
16
  static $table: string = ''
15
17
  static $schema?: DBSchema
16
18
 
19
+ static $timestamps?: boolean = false
20
+ static $createdAt?: boolean = false
21
+ static $updatedAt?: boolean = false
22
+
17
23
  static pipe<S, T>(): Pipe<S, T> {
18
24
  throw new Error(`Database connection not provided.`) // TODO: improv this message
19
25
  }
@@ -21,7 +27,35 @@ export default abstract class Model<TB extends keyof DB, DB> {
21
27
  static builder<S, T>() {
22
28
  const table = this.$table || pluralize(this.name.toLowerCase())
23
29
 
24
- return new QueryBuilder<S, T>(table, this.$schema, this.pipe<S, T>())
30
+ return new QueryBuilder<S, T>(table, this.$schema, this.pipe<S, T>()).opts({
31
+ timestamps: this.$timestamps,
32
+ createdAt: this.$createdAt,
33
+ updatedAt: this.$updatedAt,
34
+ })
35
+ }
36
+
37
+ static insert< // @ts-ignore
38
+ M extends typeof Model<TB, DB>,
39
+ I extends InstanceType<M>,
40
+ T extends I['$TShape'],
41
+ >(this: M, data: Record<keyof T, Value>) {
42
+ return this.builder<I['$DBShape'], T>().insert(data)
43
+ }
44
+
45
+ static update< // @ts-ignore
46
+ M extends typeof Model<TB, DB>,
47
+ I extends InstanceType<M>,
48
+ T extends I['$TShape'],
49
+ >(this: M, data: Record<keyof T, Value>) {
50
+ return this.builder<I['$DBShape'], T>().update(data)
51
+ }
52
+
53
+ static delete< // @ts-ignore
54
+ M extends typeof Model<TB, DB>,
55
+ I extends InstanceType<M>,
56
+ T extends I['$TShape'],
57
+ >(this: M) {
58
+ return this.builder<I['$DBShape'], T>().delete()
25
59
  }
26
60
 
27
61
  static select< // @ts-ignore
@@ -41,56 +75,278 @@ export default abstract class Model<TB extends keyof DB, DB> {
41
75
  return this.builder<I['$DBShape'], T>().distinct()
42
76
  }
43
77
 
44
- static where< // @ts-ignore
78
+ static join< // @ts-ignore
45
79
  M extends typeof Model<TB, DB>,
46
80
  I extends InstanceType<M>,
81
+ S extends I['$DBShape'],
47
82
  T extends I['$TShape'],
48
- C extends keyof T
49
- >(this: M, fn: WhereFn<T>): QueryBuilder<I['$DBShape'], T, C>
83
+ J extends keyof S,
84
+ >(this: M, table: J, fn: WhereFn<T>): QueryBuilder<S, T>
85
+ static join< // @ts-ignore
86
+ M extends typeof Model<TB, DB>,
87
+ I extends InstanceType<M>,
88
+ S extends I['$DBShape'],
89
+ T extends I['$TShape'],
90
+ J extends keyof S,
91
+ T1 extends S[J],
92
+ K extends keyof T1
93
+ >(table: J, column: K, value: T[K]): QueryBuilder<S, T>
94
+ static join< // @ts-ignore
95
+ M extends typeof Model<TB, DB>,
96
+ I extends InstanceType<M>,
97
+ S extends I['$DBShape'],
98
+ T extends I['$TShape'],
99
+ J extends keyof S,
100
+ T1 extends S[J],
101
+ K extends keyof T1
102
+ >(table: J, column: K, operator: Operator, value: T[K]): QueryBuilder<S, T>
103
+ static join< // @ts-ignore
104
+ M extends typeof Model<TB, DB>,
105
+ I extends InstanceType<M>,
106
+ S extends I['$DBShape'],
107
+ T extends I['$TShape'],
108
+ J extends keyof S,
109
+ T1 extends S[J],
110
+ K extends keyof T1,
111
+ J2 extends keyof S,
112
+ K2 extends keyof S[J2],
113
+ >(table: J, column: K, table2: J2, column2: K2): QueryBuilder<S, T>
114
+ static join< // @ts-ignore
115
+ M extends typeof Model<TB, DB>,
116
+ I extends InstanceType<M>,
117
+ S extends I['$DBShape'],
118
+ T extends I['$TShape'],
119
+ J extends keyof S,
120
+ T1 extends S[J],
121
+ K extends keyof T1,
122
+ J2 extends keyof S,
123
+ K2 extends keyof S[J2],
124
+ >(table: J, column: K, operator: Operator, table2: J2, column2: K2): QueryBuilder<S, T>
125
+ static join< // @ts-ignore
126
+ M extends typeof Model<TB, DB>,
127
+ I extends InstanceType<M>,
128
+ S extends I['$DBShape'],
129
+ J extends keyof S
130
+ >(this: M, table: J, ...args: JoinArgs<S, J>) { // @ts-ignore
131
+ return this.builder<S, I['$TShape']>().join(table, ...args)
132
+ }
133
+
134
+ static innerJoin< // @ts-ignore
135
+ M extends typeof Model<TB, DB>,
136
+ I extends InstanceType<M>,
137
+ S extends I['$DBShape'],
138
+ T extends I['$TShape'],
139
+ J extends keyof S,
140
+ >(this: M, table: J, fn: WhereFn<T>): QueryBuilder<S, T>
141
+ static innerJoin< // @ts-ignore
142
+ M extends typeof Model<TB, DB>,
143
+ I extends InstanceType<M>,
144
+ S extends I['$DBShape'],
145
+ T extends I['$TShape'],
146
+ J extends keyof S,
147
+ T1 extends S[J],
148
+ K extends keyof T1
149
+ >(table: J, column: K, value: T[K]): QueryBuilder<S, T>
150
+ static innerJoin< // @ts-ignore
151
+ M extends typeof Model<TB, DB>,
152
+ I extends InstanceType<M>,
153
+ S extends I['$DBShape'],
154
+ T extends I['$TShape'],
155
+ J extends keyof S,
156
+ T1 extends S[J],
157
+ K extends keyof T1
158
+ >(table: J, column: K, operator: Operator, value: T[K]): QueryBuilder<S, T>
159
+ static innerJoin< // @ts-ignore
160
+ M extends typeof Model<TB, DB>,
161
+ I extends InstanceType<M>,
162
+ S extends I['$DBShape'],
163
+ T extends I['$TShape'],
164
+ J extends keyof S,
165
+ T1 extends S[J],
166
+ K extends keyof T1,
167
+ J2 extends keyof S,
168
+ K2 extends keyof S[J2],
169
+ >(table: J, column: K, table2: J2, column2: K2): QueryBuilder<S, T>
170
+ static innerJoin< // @ts-ignore
171
+ M extends typeof Model<TB, DB>,
172
+ I extends InstanceType<M>,
173
+ S extends I['$DBShape'],
174
+ T extends I['$TShape'],
175
+ J extends keyof S,
176
+ T1 extends S[J],
177
+ K extends keyof T1,
178
+ J2 extends keyof S,
179
+ K2 extends keyof S[J2],
180
+ >(table: J, column: K, operator: Operator, table2: J2, column2: K2): QueryBuilder<S, T>
181
+ static innerJoin< // @ts-ignore
182
+ M extends typeof Model<TB, DB>,
183
+ I extends InstanceType<M>,
184
+ S extends I['$DBShape'],
185
+ J extends keyof S
186
+ >(this: M, table: J, ...args: JoinArgs<S, J>) { // @ts-ignore
187
+ return this.builder<S, I['$TShape']>().innerJoin(table, ...args)
188
+ }
189
+
190
+ static rightJoin< // @ts-ignore
191
+ M extends typeof Model<TB, DB>,
192
+ I extends InstanceType<M>,
193
+ S extends I['$DBShape'],
194
+ T extends I['$TShape'],
195
+ J extends keyof S,
196
+ >(this: M, table: J, fn: WhereFn<T>): QueryBuilder<S, T>
197
+ static rightJoin< // @ts-ignore
198
+ M extends typeof Model<TB, DB>,
199
+ I extends InstanceType<M>,
200
+ S extends I['$DBShape'],
201
+ T extends I['$TShape'],
202
+ J extends keyof S,
203
+ T1 extends S[J],
204
+ K extends keyof T1
205
+ >(table: J, column: K, value: T[K]): QueryBuilder<S, T>
206
+ static rightJoin< // @ts-ignore
207
+ M extends typeof Model<TB, DB>,
208
+ I extends InstanceType<M>,
209
+ S extends I['$DBShape'],
210
+ T extends I['$TShape'],
211
+ J extends keyof S,
212
+ T1 extends S[J],
213
+ K extends keyof T1
214
+ >(table: J, column: K, operator: Operator, value: T[K]): QueryBuilder<S, T>
215
+ static rightJoin< // @ts-ignore
216
+ M extends typeof Model<TB, DB>,
217
+ I extends InstanceType<M>,
218
+ S extends I['$DBShape'],
219
+ T extends I['$TShape'],
220
+ J extends keyof S,
221
+ T1 extends S[J],
222
+ K extends keyof T1,
223
+ J2 extends keyof S,
224
+ K2 extends keyof S[J2],
225
+ >(table: J, column: K, table2: J2, column2: K2): QueryBuilder<S, T>
226
+ static rightJoin< // @ts-ignore
227
+ M extends typeof Model<TB, DB>,
228
+ I extends InstanceType<M>,
229
+ S extends I['$DBShape'],
230
+ T extends I['$TShape'],
231
+ J extends keyof S,
232
+ T1 extends S[J],
233
+ K extends keyof T1,
234
+ J2 extends keyof S,
235
+ K2 extends keyof S[J2],
236
+ >(table: J, column: K, operator: Operator, table2: J2, column2: K2): QueryBuilder<S, T>
237
+ static rightJoin< // @ts-ignore
238
+ M extends typeof Model<TB, DB>,
239
+ I extends InstanceType<M>,
240
+ S extends I['$DBShape'],
241
+ J extends keyof S
242
+ >(this: M, table: J, ...args: JoinArgs<S, J>) { // @ts-ignore
243
+ return this.builder<S, I['$TShape']>().rightJoin(table, ...args)
244
+ }
245
+
246
+ static crossJoin< // @ts-ignore
247
+ M extends typeof Model<TB, DB>,
248
+ I extends InstanceType<M>,
249
+ S extends I['$DBShape'],
250
+ T extends I['$TShape'],
251
+ J extends keyof S,
252
+ >(this: M, table: J, fn: WhereFn<T>): QueryBuilder<S, T>
253
+ static crossJoin< // @ts-ignore
254
+ M extends typeof Model<TB, DB>,
255
+ I extends InstanceType<M>,
256
+ S extends I['$DBShape'],
257
+ T extends I['$TShape'],
258
+ J extends keyof S,
259
+ T1 extends S[J],
260
+ K extends keyof T1
261
+ >(table: J, column: K, value: T[K]): QueryBuilder<S, T>
262
+ static crossJoin< // @ts-ignore
263
+ M extends typeof Model<TB, DB>,
264
+ I extends InstanceType<M>,
265
+ S extends I['$DBShape'],
266
+ T extends I['$TShape'],
267
+ J extends keyof S,
268
+ T1 extends S[J],
269
+ K extends keyof T1
270
+ >(table: J, column: K, operator: Operator, value: T[K]): QueryBuilder<S, T>
271
+ static crossJoin< // @ts-ignore
272
+ M extends typeof Model<TB, DB>,
273
+ I extends InstanceType<M>,
274
+ S extends I['$DBShape'],
275
+ T extends I['$TShape'],
276
+ J extends keyof S,
277
+ T1 extends S[J],
278
+ K extends keyof T1,
279
+ J2 extends keyof S,
280
+ K2 extends keyof S[J2],
281
+ >(table: J, column: K, table2: J2, column2: K2): QueryBuilder<S, T>
282
+ static crossJoin< // @ts-ignore
283
+ M extends typeof Model<TB, DB>,
284
+ I extends InstanceType<M>,
285
+ S extends I['$DBShape'],
286
+ T extends I['$TShape'],
287
+ J extends keyof S,
288
+ T1 extends S[J],
289
+ K extends keyof T1,
290
+ J2 extends keyof S,
291
+ K2 extends keyof S[J2],
292
+ >(table: J, column: K, operator: Operator, table2: J2, column2: K2): QueryBuilder<S, T>
293
+ static crossJoin< // @ts-ignore
294
+ M extends typeof Model<TB, DB>,
295
+ I extends InstanceType<M>,
296
+ S extends I['$DBShape'],
297
+ J extends keyof S
298
+ >(this: M, table: J, ...args: JoinArgs<S, J>) { // @ts-ignore
299
+ return this.builder<S, I['$TShape']>().crossJoin(table, ...args)
300
+ }
301
+
302
+ static where< // @ts-ignore
303
+ M extends typeof Model<TB, DB>,
304
+ I extends InstanceType<M>,
305
+ T extends I['$TShape']
306
+ >(this: M, fn: WhereFn<T>): QueryBuilder<I['$DBShape'], T>
50
307
  static where< // @ts-ignore
51
308
  M extends typeof Model<TB, DB>,
52
309
  I extends InstanceType<M>,
53
310
  T extends I['$TShape'],
54
311
  C extends keyof T
55
- >(this: M, column: C, value: T[C]): QueryBuilder<I['$DBShape'], T, C>
312
+ >(this: M, column: C, value: T[C]): QueryBuilder<I['$DBShape'], T>
56
313
  static where< // @ts-ignore
57
314
  M extends typeof Model<TB, DB>,
58
315
  I extends InstanceType<M>,
59
316
  T extends I['$TShape'],
60
317
  C extends keyof T
61
- >(this: M, column: C, operator: Operator, value: T[C]): QueryBuilder<I['$DBShape'], T, C>
318
+ >(this: M, column: C, operator: Operator, value: T[C]): QueryBuilder<I['$DBShape'], T>
62
319
  static where< // @ts-ignore
63
320
  M extends typeof Model<TB, DB>,
64
321
  I extends InstanceType<M>,
65
322
  T extends I['$TShape']
66
- >(this: M, ...args: WhereArgs<T>) {
323
+ >(this: M, ...args: WhereArgs<T>) { // @ts-ignore
67
324
  return this.builder<I['$DBShape'], T>().where(...args)
68
325
  }
69
326
 
70
327
  static on< // @ts-ignore
71
328
  M extends typeof Model<TB, DB>,
72
329
  I extends InstanceType<M>,
73
- T extends I['$TShape'],
74
- C extends keyof T
75
- >(this: M, fn: WhereFn<T>): QueryBuilder<I['$DBShape'], T, C>
330
+ T extends I['$TShape']
331
+ >(this: M, fn: WhereFn<T>): QueryBuilder<I['$DBShape'], T>
76
332
  static on< // @ts-ignore
77
333
  M extends typeof Model<TB, DB>,
78
334
  I extends InstanceType<M>,
79
335
  T extends I['$TShape'],
80
336
  C extends keyof T
81
- >(this: M, column: C, value: T[C]): QueryBuilder<I['$DBShape'], T, C>
337
+ >(this: M, column: C, value: T[C]): QueryBuilder<I['$DBShape'], T>
82
338
  static on< // @ts-ignore
83
339
  M extends typeof Model<TB, DB>,
84
340
  I extends InstanceType<M>,
85
341
  T extends I['$TShape'],
86
342
  C extends keyof T
87
- >(this: M, column: C, operator: Operator, value: T[C]): QueryBuilder<I['$DBShape'], T, C>
343
+ >(this: M, column: C, operator: Operator, value: T[C]): QueryBuilder<I['$DBShape'], T>
88
344
  static on< // @ts-ignore
89
345
  M extends typeof Model<TB, DB>,
90
346
  I extends InstanceType<M>,
91
347
  T extends I['$TShape']
92
- >(this: M, ...args: WhereArgs<T>) {
93
- return this.builder<I['$DBShape'], T>().where(...args)
348
+ >(this: M, ...args: WhereArgs<T>) { // @ts-ignore
349
+ return this.where(...args)
94
350
  }
95
351
 
96
352
  static whereIn< // @ts-ignore