nestjs-paginate 4.10.0 → 4.12.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.
- package/README.md +40 -0
- package/lib/__tests__/cat-home-pillow.entity.d.ts +7 -0
- package/lib/__tests__/cat-home-pillow.entity.js +37 -0
- package/lib/__tests__/cat-home-pillow.entity.js.map +1 -0
- package/lib/__tests__/cat-home.entity.d.ts +2 -0
- package/lib/__tests__/cat-home.entity.js +5 -0
- package/lib/__tests__/cat-home.entity.js.map +1 -1
- package/lib/__tests__/cat.entity.js +3 -1
- package/lib/__tests__/cat.entity.js.map +1 -1
- package/lib/paginate.d.ts +3 -2
- package/lib/paginate.js +27 -6
- package/lib/paginate.js.map +1 -1
- package/lib/paginate.spec.js +71 -1
- package/lib/paginate.spec.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -261,6 +261,46 @@ const paginateConfig: PaginateConfig<CatEntity> {
|
|
|
261
261
|
}
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
+
## Eager loading
|
|
265
|
+
|
|
266
|
+
Eager loading should work with typeorm's eager property out the box. Like so
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { Entity, OneToMany } from 'typeorm';
|
|
270
|
+
|
|
271
|
+
@Entity()
|
|
272
|
+
export class CatEntity {
|
|
273
|
+
@PrimaryGeneratedColumn()
|
|
274
|
+
id: number
|
|
275
|
+
|
|
276
|
+
@Column('text')
|
|
277
|
+
name: string
|
|
278
|
+
|
|
279
|
+
@Column('text')
|
|
280
|
+
color: string
|
|
281
|
+
|
|
282
|
+
@Column('int')
|
|
283
|
+
age: number
|
|
284
|
+
|
|
285
|
+
@OneToMany(() => CatToyEntity, (catToy) => catToy.cat, {
|
|
286
|
+
eager: true,
|
|
287
|
+
})
|
|
288
|
+
toys: CatToyEntity[]
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// service
|
|
292
|
+
class CatService {
|
|
293
|
+
constructor(private readonly catsRepository: Repository<CatEntity>) {}
|
|
294
|
+
|
|
295
|
+
public findAll(query: PaginateQuery): Promise<Paginated<CatEntity>> {
|
|
296
|
+
return paginate(query, this.catsRepository, {
|
|
297
|
+
sortableColumns: ['id', 'name', 'color', 'age'],
|
|
298
|
+
loadEagerRelations: true // set this property as true to enable the eager loading
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
264
304
|
## Usage with Query Builder
|
|
265
305
|
|
|
266
306
|
You can paginate custom queries by passing on the query builder:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CatHomePillowEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const cat_home_entity_1 = require("./cat-home.entity");
|
|
15
|
+
let CatHomePillowEntity = class CatHomePillowEntity {
|
|
16
|
+
};
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
19
|
+
__metadata("design:type", Number)
|
|
20
|
+
], CatHomePillowEntity.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.ManyToOne)(() => cat_home_entity_1.CatHomeEntity, (home) => home.pillows),
|
|
23
|
+
__metadata("design:type", cat_home_entity_1.CatHomeEntity)
|
|
24
|
+
], CatHomePillowEntity.prototype, "home", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], CatHomePillowEntity.prototype, "color", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], CatHomePillowEntity.prototype, "createdAt", void 0);
|
|
33
|
+
CatHomePillowEntity = __decorate([
|
|
34
|
+
(0, typeorm_1.Entity)()
|
|
35
|
+
], CatHomePillowEntity);
|
|
36
|
+
exports.CatHomePillowEntity = CatHomePillowEntity;
|
|
37
|
+
//# sourceMappingURL=cat-home-pillow.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-home-pillow.entity.js","sourceRoot":"","sources":["../../src/__tests__/cat-home-pillow.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA6F;AAC7F,uDAAiD;AAG1C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAY/B,CAAA;AAXG;IAAC,IAAA,gCAAsB,GAAE;;+CACf;AAEV;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;8BACjD,+BAAa;iDAAA;AAEnB;IAAC,IAAA,gBAAM,GAAE;;kDACI;AAEb;IAAC,IAAA,0BAAgB,GAAE;;sDACF;AAXR,mBAAmB;IAD/B,IAAA,gBAAM,GAAE;GACI,mBAAmB,CAY/B;AAZY,kDAAmB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { CatEntity } from './cat.entity';
|
|
2
|
+
import { CatHomePillowEntity } from './cat-home-pillow.entity';
|
|
2
3
|
export declare class CatHomeEntity {
|
|
3
4
|
id: number;
|
|
4
5
|
name: string;
|
|
5
6
|
cat: CatEntity;
|
|
7
|
+
pillows: CatHomePillowEntity[];
|
|
6
8
|
createdAt: string;
|
|
7
9
|
countCat: number;
|
|
8
10
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.CatHomeEntity = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const cat_entity_1 = require("./cat.entity");
|
|
15
|
+
const cat_home_pillow_entity_1 = require("./cat-home-pillow.entity");
|
|
15
16
|
let CatHomeEntity = class CatHomeEntity {
|
|
16
17
|
};
|
|
17
18
|
__decorate([
|
|
@@ -26,6 +27,10 @@ __decorate([
|
|
|
26
27
|
(0, typeorm_1.OneToOne)(() => cat_entity_1.CatEntity, (cat) => cat.home),
|
|
27
28
|
__metadata("design:type", cat_entity_1.CatEntity)
|
|
28
29
|
], CatHomeEntity.prototype, "cat", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.OneToMany)(() => cat_home_pillow_entity_1.CatHomePillowEntity, (pillow) => pillow.home),
|
|
32
|
+
__metadata("design:type", Array)
|
|
33
|
+
], CatHomeEntity.prototype, "pillows", void 0);
|
|
29
34
|
__decorate([
|
|
30
35
|
(0, typeorm_1.CreateDateColumn)(),
|
|
31
36
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-home.entity.js","sourceRoot":"","sources":["../../src/__tests__/cat-home.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cat-home.entity.js","sourceRoot":"","sources":["../../src/__tests__/cat-home.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAsH;AACtH,6CAAwC;AACxC,qEAA8D;AAGvD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAoBzB,CAAA;AAnBG;IAAC,IAAA,gCAAsB,GAAE;;yCACf;AAEV;IAAC,IAAA,gBAAM,GAAE;;2CACG;AAEZ;IAAC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;8BACxC,sBAAS;0CAAA;AAEd;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,4CAAmB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;;8CAChC;AAE9B;IAAC,IAAA,0BAAgB,GAAE;;gDACF;AAEjB;IAAC,IAAA,uBAAa,EAAC;QACX,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,mEAAmE,KAAK,KAAK;KAClG,CAAC;;+CACc;AAnBP,aAAa;IADzB,IAAA,gBAAM,GAAE;GACI,aAAa,CAoBzB;AApBY,sCAAa"}
|
|
@@ -44,7 +44,9 @@ __decorate([
|
|
|
44
44
|
__metadata("design:type", size_embed_1.SizeEmbed)
|
|
45
45
|
], CatEntity.prototype, "size", void 0);
|
|
46
46
|
__decorate([
|
|
47
|
-
(0, typeorm_1.OneToMany)(() => cat_toy_entity_1.CatToyEntity, (catToy) => catToy.cat
|
|
47
|
+
(0, typeorm_1.OneToMany)(() => cat_toy_entity_1.CatToyEntity, (catToy) => catToy.cat, {
|
|
48
|
+
eager: true,
|
|
49
|
+
}),
|
|
48
50
|
__metadata("design:type", Array)
|
|
49
51
|
], CatEntity.prototype, "toys", void 0);
|
|
50
52
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat.entity.js","sourceRoot":"","sources":["../../src/__tests__/cat.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAYgB;AAChB,qDAA+C;AAC/C,uDAAiD;AACjD,6CAAwC;AAGjC,IAAM,SAAS,iBA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A,mBAAS,GAAE;;0CACQ;AAEpB;IAAC,IAAA,mBAAS,GAAE;IACZ,yDAAyD;IACzD,mGAAmG;;;;;0CAKlG;AA1CQ,SAAS;IADrB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;GACX,SAAS,CA2CrB;AA3CY,8BAAS"}
|
package/lib/paginate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Repository, SelectQueryBuilder, FindOptionsWhere, ObjectLiteral } from 'typeorm';
|
|
1
|
+
import { Repository, SelectQueryBuilder, FindOptionsWhere, FindOptionsRelations, ObjectLiteral } from 'typeorm';
|
|
2
2
|
import { PaginateQuery } from './decorator';
|
|
3
3
|
import { Column, RelationColumn, SortBy } from './helper';
|
|
4
4
|
import { FilterOperator, FilterSuffix } from './operator';
|
|
@@ -25,7 +25,7 @@ export declare class Paginated<T> {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export interface PaginateConfig<T> {
|
|
28
|
-
relations?: RelationColumn<T>[];
|
|
28
|
+
relations?: FindOptionsRelations<T> | RelationColumn<T>[];
|
|
29
29
|
sortableColumns: Column<T>[];
|
|
30
30
|
nullSort?: 'first' | 'last';
|
|
31
31
|
searchableColumns?: Column<T>[];
|
|
@@ -37,6 +37,7 @@ export interface PaginateConfig<T> {
|
|
|
37
37
|
filterableColumns?: {
|
|
38
38
|
[key in Column<T>]?: (FilterOperator | FilterSuffix)[];
|
|
39
39
|
};
|
|
40
|
+
loadEagerRelations?: boolean;
|
|
40
41
|
withDeleted?: boolean;
|
|
41
42
|
relativePath?: boolean;
|
|
42
43
|
origin?: string;
|
package/lib/paginate.js
CHANGED
|
@@ -15,7 +15,6 @@ exports.DEFAULT_MAX_LIMIT = 100;
|
|
|
15
15
|
exports.DEFAULT_LIMIT = 20;
|
|
16
16
|
exports.NO_PAGINATION = 0;
|
|
17
17
|
async function paginate(query, repo, config) {
|
|
18
|
-
var _a;
|
|
19
18
|
const page = (0, helper_1.positiveNumberOrDefault)(query.page, 1, 1);
|
|
20
19
|
const defaultLimit = config.defaultLimit || exports.DEFAULT_LIMIT;
|
|
21
20
|
const maxLimit = (0, helper_1.positiveNumberOrDefault)(config.maxLimit, exports.DEFAULT_MAX_LIMIT);
|
|
@@ -75,7 +74,12 @@ async function paginate(query, repo, config) {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
let [items, totalItems] = [[], 0];
|
|
78
|
-
const queryBuilder = repo instanceof typeorm_1.Repository ? repo.createQueryBuilder('
|
|
77
|
+
const queryBuilder = repo instanceof typeorm_1.Repository ? repo.createQueryBuilder('__root') : repo;
|
|
78
|
+
if (repo instanceof typeorm_1.Repository && !config.relations && config.loadEagerRelations === true) {
|
|
79
|
+
if (!config.relations) {
|
|
80
|
+
typeorm_1.FindOptionsUtils.joinEagerRelations(queryBuilder, queryBuilder.alias, repo.metadata);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
79
83
|
if (isPaginated) {
|
|
80
84
|
// Switch from take and skip to limit and offset
|
|
81
85
|
// due to this problem https://github.com/typeorm/typeorm/issues/5670
|
|
@@ -83,10 +87,27 @@ async function paginate(query, repo, config) {
|
|
|
83
87
|
// queryBuilder.limit(limit).offset((page - 1) * limit)
|
|
84
88
|
queryBuilder.take(limit).skip((page - 1) * limit);
|
|
85
89
|
}
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
if (config.relations) {
|
|
91
|
+
// relations: ["relation"]
|
|
92
|
+
if (Array.isArray(config.relations)) {
|
|
93
|
+
config.relations.forEach((relation) => {
|
|
94
|
+
queryBuilder.leftJoinAndSelect(`${queryBuilder.alias}.${relation}`, `${queryBuilder.alias}_${relation}`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// relations: {relation:true}
|
|
99
|
+
const createQueryBuilderRelations = (prefix, relations, alias) => {
|
|
100
|
+
Object.keys(relations).forEach((relationName) => {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
const relationSchema = relations[relationName];
|
|
103
|
+
queryBuilder.leftJoinAndSelect(`${alias !== null && alias !== void 0 ? alias : prefix}.${relationName}`, `${alias !== null && alias !== void 0 ? alias : prefix}_${relationName}`);
|
|
104
|
+
if (typeof relationSchema === 'object') {
|
|
105
|
+
createQueryBuilderRelations(relationName, relationSchema, `${prefix}_${relationName}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
createQueryBuilderRelations(queryBuilder.alias, config.relations);
|
|
110
|
+
}
|
|
90
111
|
}
|
|
91
112
|
let nullSort = undefined;
|
|
92
113
|
if (config.nullSort) {
|
package/lib/paginate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../src/paginate.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../src/paginate.ts"],"names":[],"mappings":";;;AAAA,qCAQgB;AAEhB,2CAAoE;AACpE,mCAAgC;AAChC,6CAAuC;AAEvC,qCAWiB;AAEjB,qCAAoC;AAEpC,MAAM,MAAM,GAAW,IAAI,eAAM,CAAC,iBAAiB,CAAC,CAAA;AAEpD,MAAa,SAAS;CAmBrB;AAnBD,8BAmBC;AAqBY,QAAA,iBAAiB,GAAG,GAAG,CAAA;AACvB,QAAA,aAAa,GAAG,EAAE,CAAA;AAClB,QAAA,aAAa,GAAG,CAAC,CAAA;AAEvB,KAAK,UAAU,QAAQ,CAC1B,KAAoB,EACpB,IAA2C,EAC3C,MAAyB;IAEzB,MAAM,IAAI,GAAG,IAAA,gCAAuB,EAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEtD,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,qBAAa,CAAA;IACzD,MAAM,QAAQ,GAAG,IAAA,gCAAuB,E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AI,EAAE,KAAK;QACX,IAAI,EAAE;YACF,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;YAChD,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;YACnD,WAAW,EAAE,IAAI;YACjB,UAAU;YACV,MAAM;YACN,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YAC7C,MAAM,EAAE,KAAK,CAAC,MAAM;SACvB;QACD,KAAK,EAAE;YACH,KAAK,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3C,QAAQ,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;YACxD,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC;YACxB,IAAI,EAAE,IAAI,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;YAC7D,IAAI,EAAE,IAAI,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC;SAC9E;KACJ,CAAA;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,SAAS,EAAK,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC;AArPD,4BAqPC"}
|
package/lib/paginate.spec.js
CHANGED
|
@@ -6,6 +6,7 @@ const common_1 = require("@nestjs/common");
|
|
|
6
6
|
const cat_entity_1 = require("./__tests__/cat.entity");
|
|
7
7
|
const cat_toy_entity_1 = require("./__tests__/cat-toy.entity");
|
|
8
8
|
const cat_home_entity_1 = require("./__tests__/cat-home.entity");
|
|
9
|
+
const cat_home_pillow_entity_1 = require("./__tests__/cat-home-pillow.entity");
|
|
9
10
|
const lodash_1 = require("lodash");
|
|
10
11
|
const operator_1 = require("./operator");
|
|
11
12
|
const filter_1 = require("./filter");
|
|
@@ -14,21 +15,24 @@ describe('paginate', () => {
|
|
|
14
15
|
let catRepo;
|
|
15
16
|
let catToyRepo;
|
|
16
17
|
let catHomeRepo;
|
|
18
|
+
let catHomePillowRepo;
|
|
17
19
|
let cats;
|
|
18
20
|
let catToys;
|
|
19
21
|
let catHomes;
|
|
22
|
+
let catHomePillows;
|
|
20
23
|
beforeAll(async () => {
|
|
21
24
|
dataSource = new typeorm_1.DataSource({
|
|
22
25
|
type: 'sqlite',
|
|
23
26
|
database: ':memory:',
|
|
24
27
|
synchronize: true,
|
|
25
28
|
logging: false,
|
|
26
|
-
entities: [cat_entity_1.CatEntity, cat_toy_entity_1.CatToyEntity, cat_home_entity_1.CatHomeEntity],
|
|
29
|
+
entities: [cat_entity_1.CatEntity, cat_toy_entity_1.CatToyEntity, cat_home_entity_1.CatHomeEntity, cat_home_pillow_entity_1.CatHomePillowEntity],
|
|
27
30
|
});
|
|
28
31
|
await dataSource.initialize();
|
|
29
32
|
catRepo = dataSource.getRepository(cat_entity_1.CatEntity);
|
|
30
33
|
catToyRepo = dataSource.getRepository(cat_toy_entity_1.CatToyEntity);
|
|
31
34
|
catHomeRepo = dataSource.getRepository(cat_home_entity_1.CatHomeEntity);
|
|
35
|
+
catHomePillowRepo = dataSource.getRepository(cat_home_pillow_entity_1.CatHomePillowEntity);
|
|
32
36
|
cats = await catRepo.save([
|
|
33
37
|
catRepo.create({ name: 'Milo', color: 'brown', age: 6, size: { height: 25, width: 10, length: 40 } }),
|
|
34
38
|
catRepo.create({ name: 'Garfield', color: 'ginger', age: 5, size: { height: 30, width: 15, length: 45 } }),
|
|
@@ -46,6 +50,14 @@ describe('paginate', () => {
|
|
|
46
50
|
catHomeRepo.create({ name: 'Box', cat: cats[0] }),
|
|
47
51
|
catHomeRepo.create({ name: 'House', cat: cats[1] }),
|
|
48
52
|
]);
|
|
53
|
+
catHomePillows = await catHomePillowRepo.save([
|
|
54
|
+
catHomePillowRepo.create({ color: 'red', home: catHomes[0] }),
|
|
55
|
+
catHomePillowRepo.create({ color: 'yellow', home: catHomes[0] }),
|
|
56
|
+
catHomePillowRepo.create({ color: 'blue', home: catHomes[0] }),
|
|
57
|
+
catHomePillowRepo.create({ color: 'pink', home: catHomes[1] }),
|
|
58
|
+
catHomePillowRepo.create({ color: 'purple', home: catHomes[1] }),
|
|
59
|
+
catHomePillowRepo.create({ color: 'teal', home: catHomes[1] }),
|
|
60
|
+
]);
|
|
49
61
|
// add friends to Milo
|
|
50
62
|
catRepo.save(Object.assign(Object.assign({}, cats[0]), { friends: cats.slice(1) }));
|
|
51
63
|
});
|
|
@@ -457,6 +469,49 @@ describe('paginate', () => {
|
|
|
457
469
|
expect(result.data).toStrictEqual([catHomesClone]);
|
|
458
470
|
expect(result.links.current).toBe('?page=1&limit=20&sortBy=id:ASC&search=Garfield');
|
|
459
471
|
});
|
|
472
|
+
it('should load nested relations', async () => {
|
|
473
|
+
const config = {
|
|
474
|
+
relations: { home: { pillows: true } },
|
|
475
|
+
sortableColumns: ['id', 'name'],
|
|
476
|
+
searchableColumns: ['name'],
|
|
477
|
+
};
|
|
478
|
+
const query = {
|
|
479
|
+
path: '',
|
|
480
|
+
search: 'Garfield',
|
|
481
|
+
};
|
|
482
|
+
const result = await (0, paginate_1.paginate)(query, catRepo, config);
|
|
483
|
+
const cat = (0, lodash_1.clone)(cats[1]);
|
|
484
|
+
const catHomesClone = (0, lodash_1.clone)(catHomes[1]);
|
|
485
|
+
const catHomePillowsClone3 = (0, lodash_1.clone)(catHomePillows[3]);
|
|
486
|
+
delete catHomePillowsClone3.home;
|
|
487
|
+
const catHomePillowsClone4 = (0, lodash_1.clone)(catHomePillows[4]);
|
|
488
|
+
delete catHomePillowsClone4.home;
|
|
489
|
+
const catHomePillowsClone5 = (0, lodash_1.clone)(catHomePillows[5]);
|
|
490
|
+
delete catHomePillowsClone5.home;
|
|
491
|
+
catHomesClone.countCat = cats.filter((cat) => cat.id === catHomesClone.cat.id).length;
|
|
492
|
+
catHomesClone.pillows = [catHomePillowsClone3, catHomePillowsClone4, catHomePillowsClone5];
|
|
493
|
+
cat.home = catHomesClone;
|
|
494
|
+
delete cat.home.cat;
|
|
495
|
+
expect(result.meta.search).toStrictEqual('Garfield');
|
|
496
|
+
expect(result.data).toStrictEqual([cat]);
|
|
497
|
+
expect(result.data[0].home).toBeDefined();
|
|
498
|
+
expect(result.data[0].home.pillows).toStrictEqual(cat.home.pillows);
|
|
499
|
+
});
|
|
500
|
+
it('should throw an error when nonexistent relation loaded', async () => {
|
|
501
|
+
const config = {
|
|
502
|
+
relations: ['homee'],
|
|
503
|
+
sortableColumns: ['id'],
|
|
504
|
+
};
|
|
505
|
+
const query = {
|
|
506
|
+
path: '',
|
|
507
|
+
};
|
|
508
|
+
try {
|
|
509
|
+
await (0, paginate_1.paginate)(query, catRepo, config);
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
expect(err).toBeInstanceOf(typeorm_1.TypeORMError);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
460
515
|
it('should return result based on search term and searchBy columns', async () => {
|
|
461
516
|
const config = {
|
|
462
517
|
sortableColumns: ['id', 'name', 'color'],
|
|
@@ -1624,5 +1679,20 @@ describe('paginate', () => {
|
|
|
1624
1679
|
const result = await (0, paginate_1.paginate)(query, catRepo, config);
|
|
1625
1680
|
expect(result.data.length).toBe(4);
|
|
1626
1681
|
});
|
|
1682
|
+
it('should return eager relations when set the property `loadEagerRelations` as true', async () => {
|
|
1683
|
+
const config = {
|
|
1684
|
+
sortableColumns: ['id'],
|
|
1685
|
+
defaultSortBy: [['id', 'ASC']],
|
|
1686
|
+
loadEagerRelations: true,
|
|
1687
|
+
searchableColumns: ['name'],
|
|
1688
|
+
};
|
|
1689
|
+
const query = {
|
|
1690
|
+
path: '',
|
|
1691
|
+
search: 'Garfield',
|
|
1692
|
+
};
|
|
1693
|
+
const result = await (0, paginate_1.paginate)(query, catRepo, config);
|
|
1694
|
+
expect(result.data[0].toys).toBeDefined();
|
|
1695
|
+
expect(result.data[0].toys).toHaveLength(1);
|
|
1696
|
+
});
|
|
1627
1697
|
});
|
|
1628
1698
|
//# sourceMappingURL=paginate.spec.js.map
|