@mikro-orm/knex 6.0.0-dev.19 → 6.0.0-dev.191

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 (44) 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 +390 -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 +4 -8
  14. package/SqlEntityRepository.d.ts +7 -6
  15. package/SqlEntityRepository.js +11 -8
  16. package/index.mjs +24 -5
  17. package/package.json +8 -8
  18. package/query/ArrayCriteriaNode.d.ts +4 -3
  19. package/query/ArrayCriteriaNode.js +5 -0
  20. package/query/CriteriaNode.d.ts +10 -8
  21. package/query/CriteriaNode.js +23 -10
  22. package/query/CriteriaNodeFactory.d.ts +6 -6
  23. package/query/CriteriaNodeFactory.js +28 -14
  24. package/query/ObjectCriteriaNode.d.ts +4 -3
  25. package/query/ObjectCriteriaNode.js +51 -18
  26. package/query/QueryBuilder.d.ts +50 -24
  27. package/query/QueryBuilder.js +401 -133
  28. package/query/QueryBuilderHelper.d.ts +11 -16
  29. package/query/QueryBuilderHelper.js +194 -155
  30. package/query/ScalarCriteriaNode.d.ts +3 -2
  31. package/query/ScalarCriteriaNode.js +10 -6
  32. package/query/enums.d.ts +7 -0
  33. package/query/enums.js +10 -2
  34. package/schema/DatabaseSchema.d.ts +5 -2
  35. package/schema/DatabaseSchema.js +28 -10
  36. package/schema/DatabaseTable.d.ts +13 -5
  37. package/schema/DatabaseTable.js +385 -60
  38. package/schema/SchemaComparator.d.ts +5 -5
  39. package/schema/SchemaComparator.js +59 -35
  40. package/schema/SchemaHelper.d.ts +7 -5
  41. package/schema/SchemaHelper.js +25 -11
  42. package/schema/SqlSchemaGenerator.d.ts +3 -6
  43. package/schema/SqlSchemaGenerator.js +71 -36
  44. package/typings.d.ts +22 -10
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, QueryFlag } 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,12 @@ 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;
129
+ innerJoin(field: string, alias: string, cond?: QBFilterQuery): this;
123
130
  leftJoin(field: string, alias: string, cond?: QBFilterQuery): this;
124
131
  joinAndSelect(field: string, alias: string, cond?: QBFilterQuery): this;
125
- leftJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery): this;
132
+ leftJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery, fields?: string[]): this;
133
+ innerJoinAndSelect(field: string, alias: string, cond?: QBFilterQuery, fields?: string[]): this;
126
134
  withSubQuery(subQuery: Knex.QueryBuilder, alias: string): this;
127
135
  where(cond: QBFilterQuery<T>, operator?: keyof typeof GroupOperator): this;
128
136
  where(cond: string, params?: any[], operator?: keyof typeof GroupOperator): this;
@@ -135,17 +143,21 @@ export interface IQueryBuilder<T> {
135
143
  having(cond?: QBFilterQuery | string, params?: any[]): this;
136
144
  getAliasForJoinPath(path: string): string | undefined;
137
145
  getNextAlias(entityName?: string): string;
146
+ clone(reset?: boolean): IQueryBuilder<T>;
147
+ setFlag(flag: QueryFlag): this;
148
+ unsetFlag(flag: QueryFlag): this;
149
+ hasFlag(flag: QueryFlag): boolean;
138
150
  }
139
- export interface ICriteriaNode {
151
+ export interface ICriteriaNode<T extends object> {
140
152
  readonly entityName: string;
141
- readonly parent?: ICriteriaNode | undefined;
153
+ readonly parent?: ICriteriaNode<T> | undefined;
142
154
  readonly key?: string | undefined;
143
155
  payload: any;
144
156
  prop?: EntityProperty;
145
157
  index?: number;
146
- process<T>(qb: IQueryBuilder<T>, alias?: string): any;
158
+ process(qb: IQueryBuilder<T>, alias?: string): any;
147
159
  shouldInline(payload: any): boolean;
148
- willAutoJoin<T>(qb: IQueryBuilder<T>, alias?: string): boolean;
160
+ willAutoJoin(qb: IQueryBuilder<T>, alias?: string): boolean;
149
161
  shouldRename(payload: any): boolean;
150
162
  renameFieldToPK<T>(qb: IQueryBuilder<T>): string;
151
163
  getPath(addIndex?: boolean): string;