@ptc-org/nestjs-query-core 2.2.0 → 2.3.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptc-org/nestjs-query-core",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "Base query package",
5
5
  "author": "doug-martin <doug@dougamartin.com>",
6
6
  "homepage": "https://github.com/tripss/nestjs-query#readme",
@@ -1,4 +1,5 @@
1
1
  import { Filterable } from './filterable.interface';
2
+ import { SelectRelations } from './select-relation.interface';
2
3
  import { WithDeleted } from './with-deleted.interface';
3
- export interface FindByIdOptions<DTO> extends Filterable<DTO>, WithDeleted {
4
+ export interface FindByIdOptions<DTO> extends Filterable<DTO>, SelectRelations<DTO>, WithDeleted {
4
5
  }
@@ -4,4 +4,8 @@ export interface FindRelationOptions<Relation> extends Filterable<Relation> {
4
4
  * Allow also deleted records to be retrieved
5
5
  */
6
6
  withDeleted?: boolean;
7
+ /**
8
+ * Relation is looked ahead
9
+ */
10
+ lookedAhead?: boolean;
7
11
  }
@@ -14,6 +14,7 @@ export * from './get-by-id-options.interface';
14
14
  export * from './modify-relation-options.interface';
15
15
  export * from './paging.interface';
16
16
  export * from './query.inteface';
17
+ export * from './select-relation.interface';
17
18
  export * from './query-options.interface';
18
19
  export * from './sort-field.interface';
19
20
  export * from './update-many-response.interface';
@@ -17,6 +17,7 @@ tslib_1.__exportStar(require("./get-by-id-options.interface"), exports);
17
17
  tslib_1.__exportStar(require("./modify-relation-options.interface"), exports);
18
18
  tslib_1.__exportStar(require("./paging.interface"), exports);
19
19
  tslib_1.__exportStar(require("./query.inteface"), exports);
20
+ tslib_1.__exportStar(require("./select-relation.interface"), exports);
20
21
  tslib_1.__exportStar(require("./query-options.interface"), exports);
21
22
  tslib_1.__exportStar(require("./sort-field.interface"), exports);
22
23
  tslib_1.__exportStar(require("./update-many-response.interface"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,wEAA6C;AAC7C,sEAA2C;AAC3C,yEAA8C;AAC9C,oEAAyC;AACzC,0EAA+C;AAC/C,2EAAgD;AAChD,yEAA8C;AAC9C,6DAAkC;AAClC,8EAAmD;AACnD,iEAAsC;AACtC,yEAA8C;AAC9C,4EAAiD;AACjD,wEAA6C;AAC7C,8EAAmD;AACnD,6DAAkC;AAClC,2DAAgC;AAChC,oEAAyC;AACzC,iEAAsC;AACtC,2EAAgD;AAChD,yEAA8C;AAC9C,mEAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,wEAA6C;AAC7C,sEAA2C;AAC3C,yEAA8C;AAC9C,oEAAyC;AACzC,0EAA+C;AAC/C,2EAAgD;AAChD,yEAA8C;AAC9C,6DAAkC;AAClC,8EAAmD;AACnD,iEAAsC;AACtC,yEAA8C;AAC9C,4EAAiD;AACjD,wEAA6C;AAC7C,8EAAmD;AACnD,6DAAkC;AAClC,2DAAgC;AAChC,sEAA2C;AAC3C,oEAAyC;AACzC,iEAAsC;AACtC,2EAAgD;AAChD,yEAA8C;AAC9C,mEAAwC"}
@@ -1,5 +1,6 @@
1
1
  import { Filterable } from './filterable.interface';
2
2
  import { Paging } from './paging.interface';
3
+ import { SelectRelation } from './select-relation.interface';
3
4
  import { SortField } from './sort-field.interface';
4
5
  /**
5
6
  * Interface for all queries to a collection of items.
@@ -25,7 +26,7 @@ import { SortField } from './sort-field.interface';
25
26
  *
26
27
  * @typeparam T - the type of the object to query for.
27
28
  */
28
- export interface Query<T> extends Filterable<T> {
29
+ export interface Query<DTO> extends Filterable<DTO> {
29
30
  /**
30
31
  * Option to page through the collection.
31
32
  */
@@ -33,5 +34,10 @@ export interface Query<T> extends Filterable<T> {
33
34
  /**
34
35
  * Option to sort the collection.
35
36
  */
36
- sorting?: SortField<T>[];
37
+ sorting?: SortField<DTO>[];
38
+ /**
39
+ * Select relations when doing the query.
40
+ * @internal this implementation is not final and subjected to change! Use at own risk!
41
+ */
42
+ relations?: SelectRelation<DTO>[];
37
43
  }
@@ -0,0 +1,11 @@
1
+ import { Query } from './query.inteface';
2
+ export interface SelectRelation<DTO> {
3
+ name: string;
4
+ query: Query<DTO>;
5
+ }
6
+ export interface SelectRelations<DTO> {
7
+ /**
8
+ * Select relations when doing the database query
9
+ */
10
+ relations?: SelectRelation<DTO>[];
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=select-relation.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-relation.interface.js","sourceRoot":"","sources":["../../../../../packages/core/src/interfaces/select-relation.interface.ts"],"names":[],"mappings":""}
@@ -9,6 +9,7 @@ export interface QueryService<DTO, C = DeepPartial<DTO>, U = DeepPartial<DTO>> {
9
9
  /**
10
10
  * Query for multiple records of type `T`.
11
11
  * @param query - the query used to filer, page or sort records.
12
+ * @param selectRelations - additional relation to select and fetch in the same query.
12
13
  * @returns a promise with an array of records that match the query.
13
14
  */
14
15
  query(query: Query<DTO>, opts?: QueryOptions): Promise<DTO[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/query.service.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AA0R3C;;;GAGG;AACH,4GAA4G;AAC5G,SAAgB,YAAY,CAAkD,QAAoB;IAChG,OAAO,CAA6C,GAAQ,EAAc,EAAE;QAC1E,OAAO,IAAA,mBAAU,GAAE,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC;AAJD,oCAIC"}
1
+ {"version":3,"file":"query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/query.service.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AA2R3C;;;GAGG;AACH,4GAA4G;AAC5G,SAAgB,YAAY,CAAkD,QAAoB;IAChG,OAAO,CAA6C,GAAQ,EAAc,EAAE;QAC1E,OAAO,IAAA,mBAAU,GAAE,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC;AAJD,oCAIC"}