@mikro-orm/knex 6.0.0-dev.15 → 6.0.0-dev.151

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.
Files changed (43) hide show
  1. package/AbstractSqlConnection.d.ts +8 -4
  2. package/AbstractSqlConnection.js +30 -18
  3. package/AbstractSqlDriver.d.ts +21 -23
  4. package/AbstractSqlDriver.js +394 -225
  5. package/AbstractSqlPlatform.d.ts +5 -4
  6. package/AbstractSqlPlatform.js +34 -5
  7. package/MonkeyPatchable.d.ts +1 -0
  8. package/MonkeyPatchable.js +3 -0
  9. package/PivotCollectionPersister.d.ts +17 -0
  10. package/PivotCollectionPersister.js +128 -0
  11. package/README.md +64 -107
  12. package/SqlEntityManager.d.ts +2 -6
  13. package/SqlEntityManager.js +5 -9
  14. package/SqlEntityRepository.d.ts +7 -6
  15. package/SqlEntityRepository.js +11 -8
  16. package/index.mjs +24 -6
  17. package/package.json +8 -8
  18. package/query/ArrayCriteriaNode.d.ts +3 -3
  19. package/query/CriteriaNode.d.ts +9 -8
  20. package/query/CriteriaNode.js +17 -9
  21. package/query/CriteriaNodeFactory.d.ts +6 -6
  22. package/query/CriteriaNodeFactory.js +17 -13
  23. package/query/ObjectCriteriaNode.d.ts +3 -3
  24. package/query/ObjectCriteriaNode.js +14 -10
  25. package/query/QueryBuilder.d.ts +52 -23
  26. package/query/QueryBuilder.js +389 -132
  27. package/query/QueryBuilderHelper.d.ts +11 -16
  28. package/query/QueryBuilderHelper.js +194 -155
  29. package/query/ScalarCriteriaNode.d.ts +3 -2
  30. package/query/ScalarCriteriaNode.js +10 -6
  31. package/query/enums.d.ts +7 -0
  32. package/query/enums.js +10 -2
  33. package/schema/DatabaseSchema.d.ts +5 -2
  34. package/schema/DatabaseSchema.js +27 -9
  35. package/schema/DatabaseTable.d.ts +4 -2
  36. package/schema/DatabaseTable.js +67 -32
  37. package/schema/SchemaComparator.d.ts +3 -3
  38. package/schema/SchemaComparator.js +50 -30
  39. package/schema/SchemaHelper.d.ts +6 -4
  40. package/schema/SchemaHelper.js +18 -7
  41. package/schema/SqlSchemaGenerator.d.ts +3 -6
  42. package/schema/SqlSchemaGenerator.js +69 -34
  43. package/typings.d.ts +17 -10
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaHelper = void 0;
4
4
  const core_1 = require("@mikro-orm/core");
5
5
  class SchemaHelper {
6
+ platform;
6
7
  constructor(platform) {
7
8
  this.platform = platform;
8
9
  }
@@ -46,7 +47,13 @@ class SchemaHelper {
46
47
  async getEnumDefinitions(connection, checks, tableName, schemaName) {
47
48
  return {};
48
49
  }
49
- async loadInformationSchema(schema, connection, tables) {
50
+ getDropNativeEnumSQL(name, schema) {
51
+ throw new Error('Not supported by given driver');
52
+ }
53
+ getAlterNativeEnumSQL(name, schema, value) {
54
+ throw new Error('Not supported by given driver');
55
+ }
56
+ async loadInformationSchema(schema, connection, tables, schemas) {
50
57
  for (const t of tables) {
51
58
  const table = schema.addTable(t.table_name, t.schema_name);
52
59
  table.comment = t.table_comment;
@@ -95,7 +102,7 @@ class SchemaHelper {
95
102
  }
96
103
  createTableColumn(table, column, fromTable, changedProperties) {
97
104
  const compositePK = fromTable.getPrimaryKey()?.composite;
98
- if (column.autoincrement && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
105
+ if (column.autoincrement && !column.generated && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
99
106
  const primaryKey = !changedProperties && !this.hasNonDefaultPrimaryKeyName(fromTable);
100
107
  if (column.mappedType instanceof core_1.BigIntType) {
101
108
  return table.bigIncrements(column.name, { primaryKey });
@@ -105,12 +112,16 @@ class SchemaHelper {
105
112
  if (column.mappedType instanceof core_1.EnumType && column.enumItems?.every(item => core_1.Utils.isString(item))) {
106
113
  return table.enum(column.name, column.enumItems);
107
114
  }
108
- return table.specificType(column.name, column.type);
115
+ let columnType = column.type;
116
+ if (column.generated) {
117
+ columnType += ` generated always as ${column.generated}`;
118
+ }
119
+ return table.specificType(column.name, columnType);
109
120
  }
110
121
  configureColumn(column, col, knex, changedProperties) {
111
122
  const guard = (key) => !changedProperties || changedProperties.has(key);
112
123
  core_1.Utils.runIfNotEmpty(() => col.nullable(), column.nullable && guard('nullable'));
113
- core_1.Utils.runIfNotEmpty(() => col.notNullable(), !column.nullable);
124
+ core_1.Utils.runIfNotEmpty(() => col.notNullable(), !column.nullable && !column.generated);
114
125
  core_1.Utils.runIfNotEmpty(() => col.unsigned(), column.unsigned);
115
126
  core_1.Utils.runIfNotEmpty(() => col.comment(column.comment), column.comment);
116
127
  this.configureColumnDefault(column, col, knex, changedProperties);
@@ -122,17 +133,17 @@ class SchemaHelper {
122
133
  core_1.Utils.runIfNotEmpty(() => col.defaultTo(column.default == null ? null : knex.raw(column.default)), guard('default'));
123
134
  }
124
135
  else {
125
- core_1.Utils.runIfNotEmpty(() => col.defaultTo(column.default == null ? null : knex.raw(column.default)), column.default !== undefined);
136
+ core_1.Utils.runIfNotEmpty(() => col.defaultTo(knex.raw(column.default)), column.default != null && column.default !== 'null');
126
137
  }
127
138
  return col;
128
139
  }
129
140
  getPreAlterTable(tableDiff, safe) {
130
141
  return '';
131
142
  }
132
- getAlterColumnAutoincrement(tableName, column) {
143
+ getAlterColumnAutoincrement(tableName, column, schemaName) {
133
144
  return '';
134
145
  }
135
- getChangeColumnCommentSQL(tableName, to) {
146
+ getChangeColumnCommentSQL(tableName, to, schemaName) {
136
147
  return '';
137
148
  }
138
149
  async getNamespaces(connection) {
@@ -1,5 +1,4 @@
1
- import type { MikroORM, ISchemaGenerator } from '@mikro-orm/core';
2
- import { AbstractSchemaGenerator } from '@mikro-orm/core';
1
+ import { AbstractSchemaGenerator, type MikroORM, type ISchemaGenerator } from '@mikro-orm/core';
3
2
  import type { SchemaDifference } from '../typings';
4
3
  import { DatabaseSchema } from './DatabaseSchema';
5
4
  import type { AbstractSqlDriver } from '../AbstractSqlDriver';
@@ -8,8 +7,6 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
8
7
  private readonly options;
9
8
  protected lastEnsuredDatabase?: string;
10
9
  static register(orm: MikroORM): void;
11
- /** @deprecated use `dropSchema` and `createSchema` commands respectively */
12
- generate(): Promise<string>;
13
10
  createSchema(options?: {
14
11
  wrap?: boolean;
15
12
  schema?: string;
@@ -82,10 +79,10 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
82
79
  * creates new database and connects to it
83
80
  */
84
81
  createDatabase(name: string): Promise<void>;
85
- dropDatabase(name: string): Promise<void>;
82
+ dropDatabase(name?: string): Promise<void>;
86
83
  execute(sql: string, options?: {
87
84
  wrap?: boolean;
88
- }): Promise<undefined>;
85
+ }): Promise<void>;
89
86
  private wrapSchema;
90
87
  private createSchemaBuilder;
91
88
  private createTable;
@@ -5,22 +5,12 @@ const core_1 = require("@mikro-orm/core");
5
5
  const DatabaseSchema_1 = require("./DatabaseSchema");
6
6
  const SchemaComparator_1 = require("./SchemaComparator");
7
7
  class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
8
- constructor() {
9
- super(...arguments);
10
- this.helper = this.platform.getSchemaHelper();
11
- this.options = this.config.get('schemaGenerator');
12
- }
8
+ helper = this.platform.getSchemaHelper();
9
+ options = this.config.get('schemaGenerator');
10
+ lastEnsuredDatabase;
13
11
  static register(orm) {
14
12
  orm.config.registerExtension('@mikro-orm/schema-generator', () => new SqlSchemaGenerator(orm.em));
15
13
  }
16
- /** @deprecated use `dropSchema` and `createSchema` commands respectively */
17
- async generate() {
18
- const [dropSchema, createSchema] = await Promise.all([
19
- this.getDropSchemaSQL({ wrap: false }),
20
- this.getCreateSchemaSQL({ wrap: false }),
21
- ]);
22
- return this.wrapSchema(dropSchema + createSchema);
23
- }
24
14
  async createSchema(options) {
25
15
  await this.ensureDatabase();
26
16
  const sql = await this.getCreateSchemaSQL(options);
@@ -101,7 +91,8 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
101
91
  await this.ensureDatabase();
102
92
  const wrap = options.wrap ?? this.options.disableForeignKeys;
103
93
  const metadata = this.getOrderedMetadata(options.schema).reverse();
104
- const schema = await DatabaseSchema_1.DatabaseSchema.create(this.connection, this.platform, this.config, options.schema);
94
+ const schemas = this.getTargetSchema(options.schema).getNamespaces();
95
+ const schema = await DatabaseSchema_1.DatabaseSchema.create(this.connection, this.platform, this.config, options.schema, schemas);
105
96
  let ret = '';
106
97
  // remove FKs explicitly if we can't use cascading statement and we don't disable FK checks (we need this for circular relations)
107
98
  for (const meta of metadata) {
@@ -118,6 +109,12 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
118
109
  for (const meta of metadata) {
119
110
  ret += await this.dump(this.dropTable(meta.collection, this.getSchemaName(meta, options)), '\n');
120
111
  }
112
+ if (this.platform.supportsNativeEnums()) {
113
+ for (const columnName of Object.keys(schema.getNativeEnums())) {
114
+ const sql = this.helper.getDropNativeEnumSQL(columnName, options.schema ?? this.config.get('schema'));
115
+ ret += await this.dump(this.knex.schema.raw(sql), '\n');
116
+ }
117
+ }
121
118
  if (options.dropMigrationsTable) {
122
119
  ret += await this.dump(this.dropTable(this.config.get('migrations').tableName, this.config.get('schema')), '\n');
123
120
  }
@@ -140,7 +137,9 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
140
137
  return this.diffToSQL(diffUp, options);
141
138
  }
142
139
  async getUpdateSchemaMigrationSQL(options = {}) {
143
- await this.ensureDatabase();
140
+ if (!options.fromSchema) {
141
+ await this.ensureDatabase();
142
+ }
144
143
  const { fromSchema, toSchema } = await this.prepareSchemaForComparison(options);
145
144
  const comparator = new SchemaComparator_1.SchemaComparator(this.platform);
146
145
  const diffUp = comparator.compare(fromSchema, toSchema);
@@ -151,14 +150,16 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
151
150
  };
152
151
  }
153
152
  async prepareSchemaForComparison(options) {
154
- options.wrap ?? (options.wrap = this.options.disableForeignKeys);
155
- options.safe ?? (options.safe = false);
156
- options.dropTables ?? (options.dropTables = true);
153
+ options.wrap ??= this.options.disableForeignKeys;
154
+ options.safe ??= false;
155
+ options.dropTables ??= true;
157
156
  const toSchema = this.getTargetSchema(options.schema);
158
- const fromSchema = options.fromSchema ?? await DatabaseSchema_1.DatabaseSchema.create(this.connection, this.platform, this.config, options.schema);
157
+ const schemas = toSchema.getNamespaces();
158
+ const fromSchema = options.fromSchema ?? await DatabaseSchema_1.DatabaseSchema.create(this.connection, this.platform, this.config, options.schema, schemas);
159
159
  const wildcardSchemaTables = Object.values(this.metadata.getAll()).filter(meta => meta.schema === '*').map(meta => meta.tableName);
160
160
  fromSchema.prune(options.schema, wildcardSchemaTables);
161
161
  toSchema.prune(options.schema, wildcardSchemaTables);
162
+ toSchema.setNativeEnums(fromSchema.getNativeEnums());
162
163
  return { fromSchema, toSchema };
163
164
  }
164
165
  async diffToSQL(schemaDiff, options) {
@@ -262,6 +263,12 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
262
263
  alterTable(diff, safe) {
263
264
  const ret = [];
264
265
  const [schemaName, tableName] = this.splitTableName(diff.name);
266
+ const changedNativeEnums = [];
267
+ for (const { column, changedProperties } of Object.values(diff.changedColumns)) {
268
+ if (column.nativeEnumName && changedProperties.has('enumItems') && column.nativeEnumName in diff.fromTable.nativeEnums) {
269
+ changedNativeEnums.push([column.nativeEnumName, column.enumItems, diff.fromTable.getColumn(column.name).enumItems]);
270
+ }
271
+ }
265
272
  ret.push(this.createSchemaBuilder(schemaName).alterTable(tableName, table => {
266
273
  for (const index of Object.values(diff.removedIndexes)) {
267
274
  this.dropIndex(table, index);
@@ -275,6 +282,14 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
275
282
  for (const check of Object.values(diff.changedChecks)) {
276
283
  this.dropCheck(table, check);
277
284
  }
285
+ /* istanbul ignore else */
286
+ if (!safe) {
287
+ for (const column of Object.values(diff.removedColumns)) {
288
+ this.helper.pushTableQuery(table, `alter table ${this.platform.quoteIdentifier(tableName)} drop column ${this.platform.quoteIdentifier(column.name)}`);
289
+ }
290
+ }
291
+ }));
292
+ ret.push(this.createSchemaBuilder(schemaName).alterTable(tableName, table => {
278
293
  for (const column of Object.values(diff.addedColumns)) {
279
294
  const col = this.helper.createTableColumn(table, column, diff.fromTable);
280
295
  this.helper.configureColumn(column, col, this.knex);
@@ -288,27 +303,24 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
288
303
  .onDelete(foreignKey.deleteRule);
289
304
  }
290
305
  }
291
- /* istanbul ignore else */
292
- if (!safe) {
293
- for (const column of Object.values(diff.removedColumns)) {
294
- table.dropColumn(column.name);
295
- }
296
- }
297
306
  for (const { column, changedProperties } of Object.values(diff.changedColumns)) {
298
307
  if (changedProperties.size === 1 && changedProperties.has('comment')) {
299
308
  continue;
300
309
  }
310
+ if (changedProperties.size === 1 && changedProperties.has('enumItems') && column.nativeEnumName) {
311
+ continue;
312
+ }
301
313
  const col = this.helper.createTableColumn(table, column, diff.fromTable, changedProperties).alter();
302
314
  this.helper.configureColumn(column, col, this.knex, changedProperties);
303
315
  }
304
316
  for (const { column } of Object.values(diff.changedColumns).filter(diff => diff.changedProperties.has('autoincrement'))) {
305
- this.helper.pushTableQuery(table, this.helper.getAlterColumnAutoincrement(tableName, column));
317
+ this.helper.pushTableQuery(table, this.helper.getAlterColumnAutoincrement(tableName, column, schemaName));
306
318
  }
307
319
  for (const { column, changedProperties } of Object.values(diff.changedColumns).filter(diff => diff.changedProperties.has('comment'))) {
308
320
  if (['type', 'nullable', 'autoincrement', 'unsigned', 'default', 'enumItems'].some(t => changedProperties.has(t))) {
309
321
  continue; // will be handled via knex
310
322
  }
311
- this.helper.pushTableQuery(table, this.helper.getChangeColumnCommentSQL(tableName, column));
323
+ this.helper.pushTableQuery(table, this.helper.getChangeColumnCommentSQL(tableName, column, schemaName));
312
324
  }
313
325
  for (const [oldColumnName, column] of Object.entries(diff.renamedColumns)) {
314
326
  this.helper.pushTableQuery(table, this.helper.getRenameColumnSQL(tableName, oldColumnName, column, schemaName));
@@ -345,6 +357,13 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
345
357
  table.comment(comment);
346
358
  }
347
359
  }));
360
+ if (this.platform.supportsNativeEnums()) {
361
+ changedNativeEnums.forEach(([enumName, itemsNew, itemsOld]) => {
362
+ // postgres allows only adding new items
363
+ const newItems = itemsNew.filter(val => !itemsOld.includes(val));
364
+ ret.push(...newItems.map(val => this.knex.schema.raw(this.helper.getAlterNativeEnumSQL(enumName, schemaName, val))));
365
+ });
366
+ }
348
367
  return ret;
349
368
  }
350
369
  /**
@@ -356,24 +375,26 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
356
375
  await this.driver.reconnect();
357
376
  }
358
377
  async dropDatabase(name) {
378
+ name ??= this.config.get('dbName');
359
379
  this.config.set('dbName', this.helper.getManagementDbName());
360
380
  await this.driver.reconnect();
361
381
  await this.driver.execute(this.helper.getDropDatabaseSQL('' + this.knex.ref(name)));
362
382
  }
363
383
  async execute(sql, options = {}) {
364
- options.wrap ?? (options.wrap = false);
384
+ options.wrap ??= false;
365
385
  const lines = this.wrapSchema(sql, options).split('\n').filter(i => i.trim());
366
386
  if (lines.length === 0) {
367
387
  return;
368
388
  }
369
389
  if (this.platform.supportsMultipleStatements()) {
370
390
  const query = lines.join('\n');
371
- return void await this.driver.execute(query);
391
+ await this.driver.execute(query);
392
+ return;
372
393
  }
373
394
  await core_1.Utils.runSerial(lines, line => this.driver.execute(line));
374
395
  }
375
- wrapSchema(sql, options = {}) {
376
- options.wrap ?? (options.wrap = this.options.disableForeignKeys);
396
+ wrapSchema(sql, options) {
397
+ options.wrap ??= this.options.disableForeignKeys;
377
398
  if (!options.wrap || sql.trim() === '') {
378
399
  return sql;
379
400
  }
@@ -423,7 +444,14 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
423
444
  table.primary(index.columnNames, keyName);
424
445
  }
425
446
  else if (index.unique) {
426
- table.unique(index.columnNames, { indexName: index.keyName });
447
+ // JSON columns can have unique index but not unique constraint, and we need to distinguish those, so we can properly drop them
448
+ if (index.columnNames.some(column => column.includes('.'))) {
449
+ const columns = this.platform.getJsonIndexDefinition(index);
450
+ table.index(columns.map(column => this.knex.raw(`(${column})`)), index.keyName, { indexType: 'unique' });
451
+ }
452
+ else {
453
+ table.unique(index.columnNames, { indexName: index.keyName });
454
+ }
427
455
  }
428
456
  else if (index.expression) {
429
457
  this.helper.pushTableQuery(table, index.expression);
@@ -435,14 +463,21 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
435
463
  }
436
464
  }
437
465
  else {
438
- table.index(index.columnNames, index.keyName, index.type);
466
+ // JSON columns can have unique index but not unique constraint, and we need to distinguish those, so we can properly drop them
467
+ if (index.columnNames.some(column => column.includes('.'))) {
468
+ const columns = this.platform.getJsonIndexDefinition(index);
469
+ table.index(columns.map(column => this.knex.raw(`(${column})`)), index.keyName, index.type);
470
+ }
471
+ else {
472
+ table.index(index.columnNames, index.keyName, index.type);
473
+ }
439
474
  }
440
475
  }
441
476
  dropIndex(table, index, oldIndexName = index.keyName) {
442
477
  if (index.primary) {
443
478
  table.dropPrimary(oldIndexName);
444
479
  }
445
- else if (index.unique) {
480
+ else if (index.unique && index.constraint) {
446
481
  table.dropUnique(index.columnNames, oldIndexName);
447
482
  }
448
483
  else {
package/typings.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Knex } from 'knex';
2
- import type { CheckCallback, Dictionary, EntityProperty, GroupOperator, QBFilterQuery, QueryOrderMap, Type } from '@mikro-orm/core';
3
- import type { QueryType } from './query/enums';
2
+ import type { CheckCallback, Dictionary, EntityProperty, GroupOperator, RawQueryFragment, QBFilterQuery, QueryOrderMap, Type } from '@mikro-orm/core';
3
+ import type { JoinType, QueryType } from './query/enums';
4
4
  import type { DatabaseSchema, DatabaseTable } from './schema';
5
5
  export interface Table {
6
6
  table_name: string;
@@ -11,11 +11,11 @@ export type KnexStringRef = Knex.Ref<string, {
11
11
  [alias: string]: string;
12
12
  }>;
13
13
  type AnyString = string & {};
14
- export type Field<T> = AnyString | keyof T | KnexStringRef | Knex.QueryBuilder;
14
+ export type Field<T> = AnyString | keyof T | RawQueryFragment | KnexStringRef | Knex.QueryBuilder;
15
15
  export interface JoinOptions {
16
16
  table: string;
17
17
  schema?: string;
18
- type: 'leftJoin' | 'innerJoin' | 'pivotJoin';
18
+ type: JoinType;
19
19
  alias: string;
20
20
  ownerAlias: string;
21
21
  inverseAlias?: string;
@@ -25,6 +25,8 @@ export interface JoinOptions {
25
25
  path?: string;
26
26
  prop: EntityProperty;
27
27
  cond: Dictionary;
28
+ cond_?: Dictionary;
29
+ subquery?: string;
28
30
  }
29
31
  export interface Column {
30
32
  name: string;
@@ -38,6 +40,8 @@ export interface Column {
38
40
  scale?: number;
39
41
  default?: string | null;
40
42
  comment?: string;
43
+ generated?: string;
44
+ nativeEnumName?: string;
41
45
  enumItems?: string[];
42
46
  primary?: boolean;
43
47
  unique?: boolean;
@@ -58,9 +62,11 @@ export interface IndexDef {
58
62
  columnNames: string[];
59
63
  keyName: string;
60
64
  unique: boolean;
65
+ constraint: boolean;
61
66
  primary: boolean;
62
67
  composite?: boolean;
63
68
  expression?: string;
69
+ options?: Dictionary;
64
70
  type?: string | Readonly<{
65
71
  indexType?: string;
66
72
  storageEngineIndexType?: 'hash' | 'btree';
@@ -119,10 +125,11 @@ export interface IQueryBuilder<T> {
119
125
  delete(cond?: QBFilterQuery): this;
120
126
  truncate(): this;
121
127
  count(field?: string | string[], distinct?: boolean): this;
122
- join(field: string, alias: string, cond?: QBFilterQuery, type?: 'leftJoin' | 'innerJoin' | 'pivotJoin', path?: string): this;
128
+ join(field: string, alias: string, cond?: QBFilterQuery, type?: JoinType, path?: string): this;
123
129
  leftJoin(field: string, alias: string, cond?: QBFilterQuery): this;
124
130
  joinAndSelect(field: string, alias: string, cond?: QBFilterQuery): this;
125
- leftJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery): this;
131
+ leftJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery, fields?: string[]): this;
132
+ innerJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery, fields?: string[]): this;
126
133
  withSubQuery(subQuery: Knex.QueryBuilder, alias: string): this;
127
134
  where(cond: QBFilterQuery<T>, operator?: keyof typeof GroupOperator): this;
128
135
  where(cond: string, params?: any[], operator?: keyof typeof GroupOperator): this;
@@ -136,16 +143,16 @@ export interface IQueryBuilder<T> {
136
143
  getAliasForJoinPath(path: string): string | undefined;
137
144
  getNextAlias(entityName?: string): string;
138
145
  }
139
- export interface ICriteriaNode {
146
+ export interface ICriteriaNode<T extends object> {
140
147
  readonly entityName: string;
141
- readonly parent?: ICriteriaNode | undefined;
148
+ readonly parent?: ICriteriaNode<T> | undefined;
142
149
  readonly key?: string | undefined;
143
150
  payload: any;
144
151
  prop?: EntityProperty;
145
152
  index?: number;
146
- process<T>(qb: IQueryBuilder<T>, alias?: string): any;
153
+ process(qb: IQueryBuilder<T>, alias?: string): any;
147
154
  shouldInline(payload: any): boolean;
148
- willAutoJoin<T>(qb: IQueryBuilder<T>, alias?: string): boolean;
155
+ willAutoJoin(qb: IQueryBuilder<T>, alias?: string): boolean;
149
156
  shouldRename(payload: any): boolean;
150
157
  renameFieldToPK<T>(qb: IQueryBuilder<T>): string;
151
158
  getPath(addIndex?: boolean): string;