typeorm-extensions 2.0.0 → 2.2.0-rc.0

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -8
  3. package/dist/decorators/calculated-column.decorator.d.ts +30 -0
  4. package/dist/decorators/calculated-column.decorator.js +82 -0
  5. package/dist/decorators/index.d.ts +1 -0
  6. package/dist/decorators/index.js +17 -0
  7. package/dist/extensions/calculated-column.extension.d.ts +33 -0
  8. package/dist/extensions/calculated-column.extension.js +33 -0
  9. package/dist/extensions/cursor-pagination.extension.d.ts +2 -1
  10. package/dist/extensions/cursor-pagination.extension.js +4 -3
  11. package/dist/extensions/get-many-with-totals.extension.d.ts +9 -1
  12. package/dist/extensions/get-many-with-totals.extension.js +158 -10
  13. package/dist/extensions/index.d.ts +7 -0
  14. package/dist/extensions/index.js +7 -0
  15. package/dist/extensions/join-lateral.extension.d.ts +19 -0
  16. package/dist/extensions/join-lateral.extension.js +50 -0
  17. package/dist/extensions/join-unnest.extension.d.ts +19 -0
  18. package/dist/extensions/join-unnest.extension.js +40 -0
  19. package/dist/extensions/order.extension.js +18 -7
  20. package/dist/extensions/query-returning.extension.d.ts +29 -0
  21. package/dist/extensions/query-returning.extension.js +50 -0
  22. package/dist/extensions/typed/index.d.ts +3 -0
  23. package/dist/extensions/typed/index.js +3 -2
  24. package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +3 -2
  25. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.d.ts +24 -0
  26. package/dist/extensions/typed/typed-group-by/typed-group-by.extension.js +31 -0
  27. package/dist/extensions/typed/typed-having/typed-having.extension.d.ts +36 -0
  28. package/dist/extensions/typed/typed-having/typed-having.extension.js +42 -0
  29. package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +5 -4
  30. package/dist/extensions/typed/typed-order-by/typed-order-by-array-position.extension.d.ts +3 -2
  31. package/dist/extensions/typed/typed-order-by/typed-order-by-array-position.extension.js +10 -2
  32. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +3 -2
  33. package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +3 -2
  34. package/dist/extensions/typed/typed-root.extension.d.ts +25 -0
  35. package/dist/extensions/typed/typed-root.extension.js +13 -0
  36. package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +5 -4
  37. package/dist/extensions/typed/typed-select/typed-select.extension.js +3 -2
  38. package/dist/extensions/typed/typed-where/typed-period-filter.extension.d.ts +2 -1
  39. package/dist/extensions/typed/typed-where/typed-period-filter.extension.js +1 -1
  40. package/dist/extensions/typed/typed-where/typed-where-array.extension.d.ts +10 -9
  41. package/dist/extensions/typed/typed-where/typed-where-array.extension.js +32 -0
  42. package/dist/extensions/typed/typed-where/typed-where-ilike.extension.d.ts +7 -6
  43. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.d.ts +39 -129
  44. package/dist/extensions/typed/typed-where/typed-where-is-any.extension.js +2 -1
  45. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.d.ts +7 -6
  46. package/dist/extensions/typed/typed-where/typed-where-is-distinct-from.extension.js +1 -1
  47. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.d.ts +36 -117
  48. package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +11 -19
  49. package/dist/extensions/typed/typed-where/typed-where-json.extension.d.ts +7 -6
  50. package/dist/extensions/typed/typed-where/typed-where-json.extension.js +1 -1
  51. package/dist/extensions/typed/typed-where/typed-where-lower.extension.d.ts +7 -6
  52. package/dist/extensions/typed/typed-where/typed-where-similar.extension.d.ts +5 -4
  53. package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +30 -73
  54. package/dist/extensions/typed/typed-where/typed-where.extension.js +10 -10
  55. package/dist/extensions/union.extension.d.ts +22 -0
  56. package/dist/extensions/union.extension.js +52 -0
  57. package/dist/extensions/where-exists.extension.d.ts +50 -0
  58. package/dist/extensions/where-exists.extension.js +64 -0
  59. package/dist/extensions/where-relation-exists.extension.d.ts +38 -0
  60. package/dist/extensions/where-relation-exists.extension.js +95 -0
  61. package/dist/index.d.ts +3 -0
  62. package/dist/index.js +1 -0
  63. package/dist/types/extensions/cursor-pagination.types.d.ts +5 -0
  64. package/dist/types/extensions/get-many-with-totals.types.d.ts +19 -0
  65. package/dist/types/extensions/index.d.ts +5 -0
  66. package/dist/types/extensions/index.js +5 -0
  67. package/dist/types/extensions/join-lateral.types.d.ts +6 -0
  68. package/dist/types/extensions/join-lateral.types.js +2 -0
  69. package/dist/types/extensions/period.types.d.ts +8 -0
  70. package/dist/types/extensions/query-returning.types.d.ts +11 -0
  71. package/dist/types/extensions/query-returning.types.js +2 -0
  72. package/dist/types/extensions/typed-group-by.types.d.ts +8 -0
  73. package/dist/types/extensions/typed-group-by.types.js +2 -0
  74. package/dist/types/extensions/typed-having.types.d.ts +2 -0
  75. package/dist/types/extensions/typed-having.types.js +2 -0
  76. package/dist/types/extensions/union.types.d.ts +12 -0
  77. package/dist/types/extensions/union.types.js +2 -0
  78. package/dist/types/extensions/where.types.d.ts +1 -0
  79. package/dist/types/interfaces/config.interface.d.ts +17 -0
  80. package/dist/types/interfaces/config.interface.js +2 -0
  81. package/dist/types/interfaces/index.d.ts +1 -0
  82. package/dist/types/interfaces/index.js +1 -0
  83. package/dist/types/modules/proxy-callback.types.d.ts +28 -4
  84. package/dist/types/modules/typed-params.types.d.ts +45 -0
  85. package/dist/types/modules/typed-params.types.js +2 -0
  86. package/dist/types/modules/typed-root.types.d.ts +13 -0
  87. package/dist/types/modules/typed-root.types.js +2 -0
  88. package/dist/utils/calculated-column.utils.d.ts +21 -0
  89. package/dist/utils/calculated-column.utils.js +63 -0
  90. package/dist/utils/json-path.utils.d.ts +22 -0
  91. package/dist/utils/json-path.utils.js +57 -0
  92. package/dist/utils/parameter.utils.d.ts +7 -0
  93. package/dist/utils/parameter.utils.js +21 -0
  94. package/dist/utils/period.utils.js +7 -2
  95. package/dist/utils/prototype.utils.d.ts +5 -1
  96. package/dist/utils/prototype.utils.js +4 -1
  97. package/dist/utils/proxy-key.utils.d.ts +9 -4
  98. package/dist/utils/proxy-key.utils.js +21 -14
  99. package/dist/utils/query-builder.utils.d.ts +13 -3
  100. package/dist/utils/query-builder.utils.js +95 -18
  101. package/dist/utils/sql.utils.d.ts +2 -0
  102. package/dist/utils/sql.utils.js +5 -1
  103. package/dist/utils/table.utils.d.ts +112 -2
  104. package/dist/utils/table.utils.js +206 -22
  105. package/dist/utils/time-zone.utils.d.ts +8 -0
  106. package/dist/utils/time-zone.utils.js +102 -0
  107. package/dist/utils/where.utils.d.ts +2 -2
  108. package/dist/utils/where.utils.js +23 -2
  109. package/package.json +4 -3
@@ -4,27 +4,19 @@ require("../../where-is-in.extension");
4
4
  const typeorm_1 = require("typeorm");
5
5
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
6
6
  const prototype_utils_1 = require("../../../utils/prototype.utils");
7
+ /* eslint-enable @typescript-eslint/no-empty-interface */
7
8
  // patching
9
+ const createWhereIsInTypedMethod = (method) => function (where, array) {
10
+ return attachWhereIsIn(this, method, where, array);
11
+ };
8
12
  const extension = {
9
13
  prototype: {
10
- whereIsInTyped: function (where, array) {
11
- return attachWhereIsIn(this, 'whereIsIn', where, array);
12
- },
13
- andWhereIsInTyped: function (where, array) {
14
- return attachWhereIsIn(this, 'andWhereIsIn', where, array);
15
- },
16
- orWhereIsInTyped: function (where, array) {
17
- return attachWhereIsIn(this, 'orWhereIsIn', where, array);
18
- },
19
- whereIsNotInTyped: function (where, array) {
20
- return attachWhereIsIn(this, 'whereIsNotIn', where, array);
21
- },
22
- andWhereIsNotInTyped: function (where, array) {
23
- return attachWhereIsIn(this, 'andWhereIsNotIn', where, array);
24
- },
25
- orWhereIsNotInTyped: function (where, array) {
26
- return attachWhereIsIn(this, 'orWhereIsNotIn', where, array);
27
- },
14
+ whereIsInTyped: createWhereIsInTypedMethod('whereIsIn'),
15
+ andWhereIsInTyped: createWhereIsInTypedMethod('andWhereIsIn'),
16
+ orWhereIsInTyped: createWhereIsInTypedMethod('orWhereIsIn'),
17
+ whereIsNotInTyped: createWhereIsInTypedMethod('whereIsNotIn'),
18
+ andWhereIsNotInTyped: createWhereIsInTypedMethod('andWhereIsNotIn'),
19
+ orWhereIsNotInTyped: createWhereIsInTypedMethod('orWhereIsNotIn'),
28
20
  },
29
21
  };
30
22
  const queryBuilders = [
@@ -39,7 +31,7 @@ queryBuilders.forEach((builder) => {
39
31
  function attachWhereIsIn(builder, method, where, array) {
40
32
  if (typeof where === 'function') {
41
33
  // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
42
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`);
34
+ const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value: array });
43
35
  // .andWhere(`"table"."column" IN (:...values)`, { values: ['value'] })
44
36
  return builder[method](key, array);
45
37
  }
@@ -1,6 +1,7 @@
1
1
  import '../../where-json.extension';
2
2
  import { ObjectLiteral } from 'typeorm';
3
3
  import { DeepUnwrapArray, ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
4
+ import type { TypedRoot } from '../../../types/modules/typed-root.types';
4
5
  /**
5
6
  * Typesafe conditions on PostgreSQL `jsonb` / `json` columns: the column comes from an entity property.
6
7
  * See {@link WhereJsonMethods}.
@@ -11,29 +12,29 @@ export interface TypedWhereJsonMethods<Entity extends ObjectLiteral> {
11
12
  * If you had previously WHERE expression defined,
12
13
  * calling this function will override previously set WHERE conditions.
13
14
  */
14
- whereJsonContainsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
+ whereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
15
16
  /**
16
17
  * Adds new AND WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
17
18
  */
18
- andWhereJsonContainsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
+ andWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
19
20
  /**
20
21
  * Adds new OR WHERE `column @> :value` condition (PostgreSQL): the JSON document contains `value`.
21
22
  */
22
- orWhereJsonContainsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
+ orWhereJsonContainsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: unknown): this;
23
24
  /**
24
25
  * Sets WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
25
26
  * If you had previously WHERE expression defined,
26
27
  * calling this function will override previously set WHERE conditions.
27
28
  */
28
- whereJsonHasKeyTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
29
+ whereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
29
30
  /**
30
31
  * Adds new AND WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
31
32
  */
32
- andWhereJsonHasKeyTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
33
+ andWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
33
34
  /**
34
35
  * Adds new OR WHERE `column ? :key` condition (PostgreSQL): the JSON object has the top-level key.
35
36
  */
36
- orWhereJsonHasKeyTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
37
+ orWhereJsonHasKeyTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, key: string): this;
37
38
  }
38
39
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
39
40
  interface WhereExpressionBuilder extends TypedWhereJsonMethods<ObjectLiteral> {
@@ -32,7 +32,7 @@ function attachWhereJsonTyped(builder, method, where, value) {
32
32
  if (typeof where !== 'function') {
33
33
  return builder;
34
34
  }
35
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`);
35
+ const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { accessor: 'json' });
36
36
  // .andWhereJsonContains(`"table"."column"`, { role: 'admin' }) / .andWhereJsonHasKey(`"table"."column"`, 'role')
37
37
  // (one signature for both: `value` is the JSON value or the key, each method checks its own)
38
38
  return builder[method](key, value);
@@ -1,6 +1,7 @@
1
1
  import { ObjectLiteral } from 'typeorm';
2
2
  import { DeepUnwrapArray, ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
3
3
  import type { TypedLowerOptions } from '../../../types/extensions/search.types';
4
+ import type { TypedRoot } from '../../../types/modules/typed-root.types';
4
5
  /**
5
6
  * Case-insensitive equality: `LOWER(column) = LOWER(:value)`. `options.normalize` changes the
6
7
  * wrapping of both sides, e.g. `(sql) => \`LOWER(TRIM(${sql}))\``, to match an expression index.
@@ -12,34 +13,34 @@ export interface TypedWhereLowerMethods<Entity extends ObjectLiteral> {
12
13
  * If you had previously WHERE expression defined,
13
14
  * calling this function will override previously set WHERE conditions.
14
15
  */
15
- whereLowerEqualsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
16
+ whereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
16
17
  /**
17
18
  * Adds new AND WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
18
19
  * `null` / `undefined` matches nothing (`FALSE`).
19
20
  */
20
- andWhereLowerEqualsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
21
+ andWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
21
22
  /**
22
23
  * Adds new OR WHERE `LOWER(column) = LOWER(:value)` condition in the query builder.
23
24
  * `null` / `undefined` matches nothing (`FALSE`).
24
25
  */
25
- orWhereLowerEqualsTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
26
+ orWhereLowerEqualsTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, value: string | null | undefined, options?: TypedLowerOptions): this;
26
27
  /**
27
28
  * Sets WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
28
29
  * An empty or missing array matches nothing (`FALSE`), like `whereIsIn`.
29
30
  * If you had previously WHERE expression defined,
30
31
  * calling this function will override previously set WHERE conditions.
31
32
  */
32
- whereIsInLowerTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
33
+ whereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
33
34
  /**
34
35
  * Adds new AND WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
35
36
  * An empty or missing array matches nothing (`FALSE`).
36
37
  */
37
- andWhereIsInLowerTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
38
+ andWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
38
39
  /**
39
40
  * Adds new OR WHERE `LOWER(column) IN (LOWER(:v1), LOWER(:v2), …)` condition in the query builder.
40
41
  * An empty or missing array matches nothing (`FALSE`).
41
42
  */
42
- orWhereIsInLowerTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
43
+ orWhereIsInLowerTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, values: ReadonlyArray<string> | null | undefined, options?: TypedLowerOptions): this;
43
44
  }
44
45
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
45
46
  interface WhereExpressionBuilder extends TypedWhereLowerMethods<ObjectLiteral> {
@@ -1,6 +1,7 @@
1
1
  import { ObjectLiteral } from 'typeorm';
2
2
  import { DeepUnwrapArray, ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
3
3
  import type { SimilarityScoreOptions, TypedSimilarOptions } from '../../../types/extensions/search.types';
4
+ import type { TypedRoot } from '../../../types/modules/typed-root.types';
4
5
  /**
5
6
  * Trigram similarity conditions (PostgreSQL, `pg_trgm` extension). The column is the left operand,
6
7
  * the form a `gin_trgm_ops` / `gist_trgm_ops` index on the column can be used for.
@@ -13,17 +14,17 @@ export interface TypedWhereSimilarMethods<Entity extends ObjectLiteral> {
13
14
  * If you had previously WHERE expression defined,
14
15
  * calling this function will override previously set WHERE conditions.
15
16
  */
16
- whereSimilarTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
17
+ whereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
17
18
  /**
18
19
  * Adds new AND WHERE `column % :term` condition in the query builder (PostgreSQL, pg_trgm).
19
20
  * A blank term adds no condition.
20
21
  */
21
- andWhereSimilarTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
22
+ andWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
22
23
  /**
23
24
  * Adds new OR WHERE `column % :term` condition in the query builder (PostgreSQL, pg_trgm).
24
25
  * A blank term adds no condition.
25
26
  */
26
- orWhereSimilarTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
27
+ orWhereSimilarTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, options?: TypedSimilarOptions): this;
27
28
  }
28
29
  /** Trigram similarity score selection (PostgreSQL, `pg_trgm` extension). */
29
30
  export interface TypedSimilarityScoreMethods<Entity extends ObjectLiteral> {
@@ -34,7 +35,7 @@ export interface TypedSimilarityScoreMethods<Entity extends ObjectLiteral> {
34
35
  * (`word_similarity(:term, column)`, the score of `column %> :term`).
35
36
  * Use a lower-case alias: PostgreSQL folds an unquoted alias in ORDER BY.
36
37
  */
37
- addSimilarityScoreTyped<Type extends ObjectLiteral = Entity>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, alias: string, options?: SimilarityScoreOptions): this;
38
+ addSimilarityScoreTyped<Type extends ObjectLiteral = TypedRoot<Entity>>(selection: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, term: string | null | undefined, alias: string, options?: SimilarityScoreOptions): this;
38
39
  }
39
40
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
40
41
  interface WhereExpressionBuilder extends TypedWhereSimilarMethods<ObjectLiteral> {
@@ -1,87 +1,44 @@
1
1
  import { ObjectLiteral } from 'typeorm';
2
2
  import { DeepUnwrapArray, ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
3
- import { TypedWhereOptions } from '../../../types/extensions/typed-where.types';
3
+ import { TypedWhereArgs, TypeOrDefault, UnsetType } from '../../../types/modules/typed-params.types';
4
+ import type { TypedRoot } from '../../../types/modules/typed-root.types';
5
+ /**
6
+ * Typesafe WHERE conditions: the column comes from an entity property.
7
+ * `Type` defaults to the query builder's entity; with the `strictParams` option (see `TypeormExtensionsConfig`)
8
+ * the parameter is checked against the type of the selected column.
9
+ */
10
+ export interface TypedWhereMethods<Entity extends ObjectLiteral> {
11
+ /**
12
+ * Sets WHERE condition in the query builder.
13
+ * If you had previously WHERE expression defined,
14
+ * calling this function will override previously set WHERE conditions.
15
+ * Additionally you can add parameters used in where expression.
16
+ */
17
+ whereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
18
+ /**
19
+ * Adds new AND WHERE condition in the query builder.
20
+ * Additionally you can add parameters used in where expression.
21
+ */
22
+ andWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
23
+ /**
24
+ * Adds new OR WHERE condition in the query builder.
25
+ * Additionally you can add parameters used in where expression.
26
+ */
27
+ orWhereTyped<Type extends ObjectLiteral = UnsetType, Value extends ProxyColumnValueType = ProxyColumnValueType, Operator extends string = string>(where: (proxy: DeepUnwrapArray<TypeOrDefault<Type, TypedRoot<Entity>>>) => Value, conditions: Operator, ...args: TypedWhereArgs<Type, Operator, Value>): this;
28
+ }
4
29
  declare module 'typeorm/query-builder/WhereExpressionBuilder' {
5
- interface WhereExpressionBuilder {
6
- /**
7
- * Sets WHERE condition in the query builder.
8
- * If you had previously WHERE expression defined,
9
- * calling this function will override previously set WHERE conditions.
10
- * Additionally you can add parameters used in where expression.
11
- */
12
- whereTyped<Type extends ObjectLiteral>(subQuery: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
13
- /**
14
- * Adds new AND WHERE condition in the query builder.
15
- * Additionally you can add parameters used in where expression.
16
- */
17
- andWhereTyped<Type extends ObjectLiteral>(subQuery: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
18
- /**
19
- * Adds new OR WHERE condition in the query builder.
20
- * Additionally you can add parameters used in where expression.
21
- */
22
- orWhereTyped<Type extends ObjectLiteral>(subQuery: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
30
+ interface WhereExpressionBuilder extends TypedWhereMethods<ObjectLiteral> {
23
31
  }
24
32
  }
25
33
  declare module 'typeorm/query-builder/SelectQueryBuilder' {
26
- interface SelectQueryBuilder<Entity> {
27
- /**
28
- * Sets WHERE condition in the query builder.
29
- * If you had previously WHERE expression defined,
30
- * calling this function will override previously set WHERE conditions.
31
- * Additionally you can add parameters used in where expression.
32
- */
33
- whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
34
- /**
35
- * Adds new AND WHERE condition in the query builder.
36
- * Additionally you can add parameters used in where expression.
37
- */
38
- andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
39
- /**
40
- * Adds new OR WHERE condition in the query builder.
41
- * Additionally you can add parameters used in where expression.
42
- */
43
- orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
34
+ interface SelectQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereMethods<Entity> {
44
35
  }
45
36
  }
46
37
  declare module 'typeorm/query-builder/UpdateQueryBuilder' {
47
- interface UpdateQueryBuilder<Entity> {
48
- /**
49
- * Sets WHERE condition in the query builder.
50
- * If you had previously WHERE expression defined,
51
- * calling this function will override previously set WHERE conditions.
52
- * Additionally you can add parameters used in where expression.
53
- */
54
- whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
55
- /**
56
- * Adds new AND WHERE condition in the query builder.
57
- * Additionally you can add parameters used in where expression.
58
- */
59
- andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
60
- /**
61
- * Adds new OR WHERE condition in the query builder.
62
- * Additionally you can add parameters used in where expression.
63
- */
64
- orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
38
+ interface UpdateQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereMethods<Entity> {
65
39
  }
66
40
  }
67
41
  declare module 'typeorm/query-builder/DeleteQueryBuilder' {
68
- interface DeleteQueryBuilder<Entity> {
69
- /**
70
- * Sets WHERE condition in the query builder.
71
- * If you had previously WHERE expression defined,
72
- * calling this function will override previously set WHERE conditions.
73
- * Additionally you can add parameters used in where expression.
74
- */
75
- whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
76
- /**
77
- * Adds new AND WHERE condition in the query builder.
78
- * Additionally you can add parameters used in where expression.
79
- */
80
- andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
81
- /**
82
- * Adds new OR WHERE condition in the query builder.
83
- * Additionally you can add parameters used in where expression.
84
- */
85
- orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: DeepUnwrapArray<Type>) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
42
+ interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends TypedWhereMethods<Entity> {
86
43
  }
87
44
  }
@@ -4,18 +4,16 @@ const typeorm_1 = require("typeorm");
4
4
  const query_builder_utils_1 = require("../../../utils/query-builder.utils");
5
5
  const prototype_utils_1 = require("../../../utils/prototype.utils");
6
6
  const where_utils_1 = require("../../../utils/where.utils");
7
+ /* eslint-enable @typescript-eslint/no-empty-interface */
7
8
  // patching
9
+ const createWhereTypedMethod = (method) => function (where, conditions, parameters, options) {
10
+ return attachTypedWhere(this, method, where, conditions, parameters, options);
11
+ };
8
12
  const extension = {
9
13
  prototype: {
10
- whereTyped: function (where, operator, parameters, options) {
11
- return attachTypedWhere(this, 'where', where, operator, parameters, options);
12
- },
13
- andWhereTyped: function (where, operator, parameters, options) {
14
- return attachTypedWhere(this, 'andWhere', where, operator, parameters, options);
15
- },
16
- orWhereTyped: function (where, operator, parameters, options) {
17
- return attachTypedWhere(this, 'orWhere', where, operator, parameters, options);
18
- },
14
+ whereTyped: createWhereTypedMethod('where'),
15
+ andWhereTyped: createWhereTypedMethod('andWhere'),
16
+ orWhereTyped: createWhereTypedMethod('orWhere'),
19
17
  },
20
18
  };
21
19
  const queryBuilders = [
@@ -31,7 +29,9 @@ function attachTypedWhere(builder, method, where, conditions, parameters, option
31
29
  const { addValue } = options || {};
32
30
  if (typeof where === 'function') {
33
31
  // several columns have no single meaning (AND? OR?), and `where…` kept only the last one
34
- const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`);
32
+ // a path into a JSON column is cast to the type of the value it is compared with
33
+ const value = (0, where_utils_1.isParamsObject)(parameters) ? Object.values(parameters)[0] : parameters;
34
+ const key = (0, query_builder_utils_1.getTypedSingleColumnKey)(builder, where, `${method}Typed`, { value });
35
35
  return (0, where_utils_1.attachWhere)(builder, method, key, conditions, parameters, {
36
36
  addValue,
37
37
  });
@@ -0,0 +1,22 @@
1
+ import { ObjectLiteral } from 'typeorm';
2
+ import type { UnionCteOptions, UnionOptions, UnionQuery } from '../types/extensions/union.types';
3
+ export interface UnionMethods {
4
+ /**
5
+ * Selects FROM the UNION of `queries`, as `alias`: `FROM ((A) UNION (B)) "alias"`.
6
+ *
7
+ * Unlike pasting `${a.getQuery()} UNION ${b.getQuery()}` and merging `getParameters()`, the
8
+ * parameters of each query are renamed: two queries with a `:status` of their own each keep
9
+ * their value, where a merged object keeps only the last one. A raw SQL string is used as is,
10
+ * its placeholders read the parameters of this builder.
11
+ */
12
+ fromUnion(queries: readonly UnionQuery[], alias: string, options?: UnionOptions): this;
13
+ /**
14
+ * Adds a common table expression (WITH) that is the UNION of `queries`:
15
+ * `WITH "alias" AS ((A) UNION (B))`. Parameters are renamed as in `fromUnion`.
16
+ */
17
+ addCommonTableExpressionUnion(queries: readonly UnionQuery[], alias: string, options?: UnionCteOptions): this;
18
+ }
19
+ declare module 'typeorm/query-builder/SelectQueryBuilder' {
20
+ interface SelectQueryBuilder<Entity extends ObjectLiteral> extends UnionMethods {
21
+ }
22
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const typeorm_1 = require("typeorm");
4
+ const prototype_utils_1 = require("../utils/prototype.utils");
5
+ const parameter_utils_1 = require("../utils/parameter.utils");
6
+ const sql_utils_1 = require("../utils/sql.utils");
7
+ /* eslint-enable @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars */
8
+ // patching
9
+ const extension = {
10
+ prototype: {
11
+ fromUnion(queries, alias, options) {
12
+ return this.from(`(${unionSql(this, 'fromUnion', queries, options)})`, alias);
13
+ },
14
+ addCommonTableExpressionUnion(queries, alias, options) {
15
+ const { all, ...cteOptions } = options !== null && options !== void 0 ? options : {};
16
+ return this.addCommonTableExpression(unionSql(this, 'addCommonTableExpressionUnion', queries, { all }), alias, cteOptions);
17
+ },
18
+ },
19
+ };
20
+ (0, prototype_utils_1.patchPrototype)(typeorm_1.SelectQueryBuilder, extension);
21
+ // implementation
22
+ /** The UNION of `queries`, with the parameters of each set on `builder` under unique names. */
23
+ function unionSql(builder, methodName, queries, options) {
24
+ if (!queries.length) {
25
+ throw new TypeError(`${methodName}: no queries to union`);
26
+ }
27
+ const sqlite = (0, sql_utils_1.isSqliteLikeDriver)((0, sql_utils_1.getDriverType)(builder));
28
+ const branches = queries.map((query) => {
29
+ const sql = typeof query === 'string' ? query : bindParameters(builder, query);
30
+ if (!sqlite) {
31
+ return `(${sql})`;
32
+ }
33
+ // SQLite takes neither parentheses around a part of a UNION nor an ORDER BY / LIMIT inside one
34
+ // (a query of an entity with a default `orderBy` has an ORDER BY): such a part becomes a subquery.
35
+ // Only such a part: the recursive part of a CTE can't refer to the CTE from a subquery
36
+ return ordersOrLimits(query, sql) ? `SELECT * FROM (${sql})` : sql;
37
+ });
38
+ return branches.join((options === null || options === void 0 ? void 0 : options.all) ? ' UNION ALL ' : ' UNION ');
39
+ }
40
+ const ORDER_OR_LIMIT = /\b(?:ORDER\s+BY|LIMIT|OFFSET)\b/i;
41
+ function ordersOrLimits(query, sql) {
42
+ if (typeof query === 'string' || !('expressionMap' in query)) {
43
+ return ORDER_OR_LIMIT.test(sql);
44
+ }
45
+ const { allOrderBys, limit, offset, take, skip } = query.expressionMap;
46
+ return Object.keys(allOrderBys !== null && allOrderBys !== void 0 ? allOrderBys : {}).length > 0 || [limit, offset, take, skip].some((value) => value !== undefined);
47
+ }
48
+ function bindParameters(builder, query) {
49
+ const [sql, parameters] = (0, parameter_utils_1.withUniqueParameterNames)(query.getQuery(), query.getParameters());
50
+ builder.setParameters(parameters);
51
+ return sql;
52
+ }
@@ -0,0 +1,50 @@
1
+ import { ObjectLiteral, SelectQueryBuilder, WhereExpressionBuilder } from 'typeorm';
2
+ import type { WhereMethods } from '../types/extensions';
3
+ /**
4
+ * `EXISTS` conditions. TypeORM has them on `SelectQueryBuilder` only, and keeps its own there;
5
+ * these add them to `UpdateQueryBuilder` and `DeleteQueryBuilder` with the same SQL. Unlike
6
+ * TypeORM's, they add the subquery's parameters under unique names.
7
+ */
8
+ export interface WhereExistsMethods {
9
+ /** Sets `WHERE EXISTS (subQuery)`, replacing the WHERE conditions set before. */
10
+ whereExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
11
+ /** Adds `AND EXISTS (subQuery)`. */
12
+ andWhereExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
13
+ /** Adds `OR EXISTS (subQuery)`. */
14
+ orWhereExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
15
+ }
16
+ /**
17
+ * `NOT EXISTS` conditions: the negation of TypeORM's `whereExists`, with the same subquery SQL.
18
+ * The subquery's parameters are added under unique names, so two subqueries can both use `:status`.
19
+ */
20
+ export interface WhereNotExistsMethods {
21
+ /** Sets `WHERE NOT EXISTS (subQuery)`, replacing the WHERE conditions set before. */
22
+ whereNotExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
23
+ /** Adds `AND NOT EXISTS (subQuery)`. */
24
+ andWhereNotExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
25
+ /** Adds `OR NOT EXISTS (subQuery)`. */
26
+ orWhereNotExists<SubEntity extends ObjectLiteral>(subQuery: SelectQueryBuilder<SubEntity>): this;
27
+ }
28
+ declare module 'typeorm/query-builder/WhereExpressionBuilder' {
29
+ interface WhereExpressionBuilder extends WhereExistsMethods, WhereNotExistsMethods {
30
+ }
31
+ }
32
+ declare module 'typeorm/query-builder/SelectQueryBuilder' {
33
+ interface SelectQueryBuilder<Entity extends ObjectLiteral> extends WhereNotExistsMethods {
34
+ }
35
+ }
36
+ declare module 'typeorm/query-builder/UpdateQueryBuilder' {
37
+ interface UpdateQueryBuilder<Entity extends ObjectLiteral> extends WhereExistsMethods, WhereNotExistsMethods {
38
+ }
39
+ }
40
+ declare module 'typeorm/query-builder/DeleteQueryBuilder' {
41
+ interface DeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereExistsMethods, WhereNotExistsMethods {
42
+ }
43
+ }
44
+ declare module 'typeorm/query-builder/SoftDeleteQueryBuilder' {
45
+ interface SoftDeleteQueryBuilder<Entity extends ObjectLiteral> extends WhereExistsMethods, WhereNotExistsMethods {
46
+ }
47
+ }
48
+ type SubQuery = SelectQueryBuilder<ObjectLiteral>;
49
+ export declare function attachExists<QB extends WhereExpressionBuilder>(builder: QB, method: WhereMethods, subQuery: SubQuery, negate: boolean): QB;
50
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachExists = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const SoftDeleteQueryBuilder_1 = require("typeorm/query-builder/SoftDeleteQueryBuilder");
6
+ const prototype_utils_1 = require("../utils/prototype.utils");
7
+ const parameter_utils_1 = require("../utils/parameter.utils");
8
+ const existsMethods = {
9
+ prototype: {
10
+ whereExists(subQuery) {
11
+ return attachExists(this, 'where', subQuery, false);
12
+ },
13
+ andWhereExists(subQuery) {
14
+ return attachExists(this, 'andWhere', subQuery, false);
15
+ },
16
+ orWhereExists(subQuery) {
17
+ return attachExists(this, 'orWhere', subQuery, false);
18
+ },
19
+ },
20
+ };
21
+ const notExistsMethods = {
22
+ prototype: {
23
+ whereNotExists(subQuery) {
24
+ return attachExists(this, 'where', subQuery, true);
25
+ },
26
+ andWhereNotExists(subQuery) {
27
+ return attachExists(this, 'andWhere', subQuery, true);
28
+ },
29
+ orWhereNotExists(subQuery) {
30
+ return attachExists(this, 'orWhere', subQuery, true);
31
+ },
32
+ },
33
+ };
34
+ // only where the builder lacks them: SelectQueryBuilder keeps TypeORM's own whereExists /
35
+ // andWhereExists / orWhereExists, and a later TypeORM that adds any of these keeps its own
36
+ [typeorm_1.SelectQueryBuilder, typeorm_1.UpdateQueryBuilder, typeorm_1.DeleteQueryBuilder, SoftDeleteQueryBuilder_1.SoftDeleteQueryBuilder].forEach((builder) => {
37
+ (0, prototype_utils_1.patchPrototype)(builder, existsMethods, { onlyMissing: true });
38
+ (0, prototype_utils_1.patchPrototype)(builder, notExistsMethods, { onlyMissing: true });
39
+ });
40
+ // implementation
41
+ function attachExists(builder, method, subQuery, negate) {
42
+ const [condition, parameters] = (0, parameter_utils_1.withUniqueParameterNames)(...getExistsCondition(subQuery));
43
+ return builder[method](negate ? `NOT ${condition}` : condition, parameters);
44
+ }
45
+ exports.attachExists = attachExists;
46
+ /**
47
+ * TypeORM's EXISTS condition: the subquery selects 1, without ORDER BY, LIMIT and OFFSET. TypeORM also
48
+ * drops GROUP BY, which leaves a HAVING to aggregate the whole subquery: the GROUP BY stays with one.
49
+ */
50
+ function getExistsCondition(subQuery) {
51
+ const query = subQuery
52
+ .clone()
53
+ .orderBy()
54
+ .offset(undefined)
55
+ .limit(undefined)
56
+ .skip(undefined)
57
+ .take(undefined)
58
+ .select('1')
59
+ .setOption('disable-global-order');
60
+ if (query.expressionMap.havings.length === 0) {
61
+ query.groupBy();
62
+ }
63
+ return [`EXISTS (${query.getQuery()})`, query.getParameters()];
64
+ }
@@ -0,0 +1,38 @@
1
+ import { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
2
+ import type { DeepUnwrapArray, KeyPathEnd } from '../types/modules/proxy-callback.types';
3
+ import type { TypedRoot } from '../types/modules/typed-root.types';
4
+ /**
5
+ * The relation to look in, selected by a typed callback: `user => user.images`. A relation of a joined alias
6
+ * (`joins => joins.owner.images`) ends the key path, so its entity type isn't known: pass it as `Related`.
7
+ */
8
+ type RelationSelection<Type, Related> = (proxy: DeepUnwrapArray<Type>) => Related | KeyPathEnd | null | undefined;
9
+ /** Narrows the rows of the related entity: `images => images.andWhere('images.url IS NOT NULL')`. */
10
+ type RelatedCondition<Related extends ObjectLiteral> = (subQuery: SelectQueryBuilder<Related>) => unknown;
11
+ /**
12
+ * `EXISTS` / `NOT EXISTS` over a relation of an entity, with the join condition taken from the relation's
13
+ * metadata: `andWhereRelationExists(user => user.images, 'image', (images) => images.andWhere(…))` gives
14
+ * `EXISTS (SELECT 1 FROM "images" "image" WHERE … AND "image"."userId" = "user"."id")`. Works for
15
+ * one-to-many, many-to-one, one-to-one and many-to-many (through the junction table) relations.
16
+ *
17
+ * `alias` names the related entity in the subquery and must not be an alias of the outer query.
18
+ * The subquery's parameters get unique names, as in `whereNotExists`.
19
+ */
20
+ export interface WhereRelationExistsMethods<Entity extends ObjectLiteral> {
21
+ /** Sets `WHERE EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
22
+ whereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
23
+ /** Adds `AND EXISTS (…)` over the relation. */
24
+ andWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
25
+ /** Adds `OR EXISTS (…)` over the relation. */
26
+ orWhereRelationExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
27
+ /** Sets `WHERE NOT EXISTS (…)` over the relation, replacing the WHERE conditions set before. */
28
+ whereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
29
+ /** Adds `AND NOT EXISTS (…)` over the relation. */
30
+ andWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
31
+ /** Adds `OR NOT EXISTS (…)` over the relation. */
32
+ orWhereRelationNotExists<Related extends ObjectLiteral, Type extends ObjectLiteral = TypedRoot<Entity>>(relation: RelationSelection<Type, Related>, alias: string, where?: RelatedCondition<Related>): this;
33
+ }
34
+ declare module 'typeorm/query-builder/SelectQueryBuilder' {
35
+ interface SelectQueryBuilder<Entity extends ObjectLiteral> extends WhereRelationExistsMethods<Entity> {
36
+ }
37
+ }
38
+ export {};