File tree Expand file tree Collapse file tree 18 files changed +110
-363
lines changed Expand file tree Collapse file tree 18 files changed +110
-363
lines changed Original file line number Diff line number Diff line change @@ -1195,8 +1195,8 @@ export async function generateModelString(
1195
1195
.select(sql\`SUM(\${sql.raw(field as string)})\`)
1196
1196
.executeTakeFirst()
1197
1197
}
1198
-
1199
- async get (): Promise<${ modelName } Model[]> {
1198
+
1199
+ async applyGet (): Promise<${ modelName } Model[]> {
1200
1200
let models
1201
1201
1202
1202
if (this.hasSelect) {
@@ -1216,30 +1216,14 @@ export async function generateModelString(
1216
1216
return data
1217
1217
}
1218
1218
1219
+ async get(): Promise<${ modelName } Model[]> {
1220
+ return await this.applyGet()
1221
+ }
1222
+
1219
1223
static async get(): Promise<${ modelName } Model[]> {
1220
1224
const instance = new ${ modelName } Model(null)
1221
-
1222
- let models
1223
-
1224
- if (instance.hasSelect) {
1225
- ${ instanceSoftDeleteStatementsSelectFrom }
1226
-
1227
- models = await instance.selectFromQuery.execute()
1228
- } else {
1229
- ${ instanceSoftDeleteStatementsSelectFrom }
1230
-
1231
- models = await instance.selectFromQuery.selectAll().execute()
1232
- }
1233
-
1234
- const data = await Promise.all(models.map(async (model: ${ modelName } Model) => {
1235
- const instance = new ${ modelName } Model(model)
1236
-
1237
- const results = await instance.mapWith(model)
1238
-
1239
- return new ${ modelName } Model(results)
1240
- }))
1241
-
1242
- return data
1225
+
1226
+ return await instance.applyGet()
1243
1227
}
1244
1228
1245
1229
has(relation: string): ${ modelName } Model {
Original file line number Diff line number Diff line change @@ -423,7 +423,7 @@ export class AccessTokenModel {
423
423
. executeTakeFirst ( )
424
424
}
425
425
426
- async get ( ) : Promise < AccessTokenModel [ ] > {
426
+ async applyGet ( ) : Promise < AccessTokenModel [ ] > {
427
427
let models
428
428
429
429
if ( this . hasSelect ) {
@@ -444,27 +444,14 @@ export class AccessTokenModel {
444
444
return data
445
445
}
446
446
447
+ async get ( ) : Promise < AccessTokenModel [ ] > {
448
+ return await this . applyGet ( )
449
+ }
450
+
447
451
static async get ( ) : Promise < AccessTokenModel [ ] > {
448
452
const instance = new AccessTokenModel ( null )
449
453
450
- let models
451
-
452
- if ( instance . hasSelect ) {
453
- models = await instance . selectFromQuery . execute ( )
454
- }
455
- else {
456
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
457
- }
458
-
459
- const data = await Promise . all ( models . map ( async ( model : AccessTokenModel ) => {
460
- const instance = new AccessTokenModel ( model )
461
-
462
- const results = await instance . mapWith ( model )
463
-
464
- return new AccessTokenModel ( results )
465
- } ) )
466
-
467
- return data
454
+ return await instance . applyGet ( )
468
455
}
469
456
470
457
has ( relation : string ) : AccessTokenModel {
Original file line number Diff line number Diff line change @@ -442,7 +442,7 @@ export class ActivityModel {
442
442
. executeTakeFirst ( )
443
443
}
444
444
445
- async get ( ) : Promise < ActivityModel [ ] > {
445
+ async applyGet ( ) : Promise < ActivityModel [ ] > {
446
446
let models
447
447
448
448
if ( this . hasSelect ) {
@@ -463,35 +463,14 @@ export class ActivityModel {
463
463
return data
464
464
}
465
465
466
+ async get ( ) : Promise < ActivityModel [ ] > {
467
+ return await this . applyGet ( )
468
+ }
469
+
466
470
static async get ( ) : Promise < ActivityModel [ ] > {
467
471
const instance = new ActivityModel ( null )
468
472
469
- let models
470
-
471
- if ( instance . hasSelect ) {
472
- if ( instance . softDeletes ) {
473
- instance . selectFromQuery = instance . selectFromQuery . where ( 'deleted_at' , 'is' , null )
474
- }
475
-
476
- models = await instance . selectFromQuery . execute ( )
477
- }
478
- else {
479
- if ( instance . softDeletes ) {
480
- instance . selectFromQuery = instance . selectFromQuery . where ( 'deleted_at' , 'is' , null )
481
- }
482
-
483
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
484
- }
485
-
486
- const data = await Promise . all ( models . map ( async ( model : ActivityModel ) => {
487
- const instance = new ActivityModel ( model )
488
-
489
- const results = await instance . mapWith ( model )
490
-
491
- return new ActivityModel ( results )
492
- } ) )
493
-
494
- return data
473
+ return await instance . applyGet ( )
495
474
}
496
475
497
476
has ( relation : string ) : ActivityModel {
Original file line number Diff line number Diff line change @@ -460,7 +460,7 @@ export class DeploymentModel {
460
460
. executeTakeFirst ( )
461
461
}
462
462
463
- async get ( ) : Promise < DeploymentModel [ ] > {
463
+ async applyGet ( ) : Promise < DeploymentModel [ ] > {
464
464
let models
465
465
466
466
if ( this . hasSelect ) {
@@ -481,27 +481,14 @@ export class DeploymentModel {
481
481
return data
482
482
}
483
483
484
+ async get ( ) : Promise < DeploymentModel [ ] > {
485
+ return await this . applyGet ( )
486
+ }
487
+
484
488
static async get ( ) : Promise < DeploymentModel [ ] > {
485
489
const instance = new DeploymentModel ( null )
486
490
487
- let models
488
-
489
- if ( instance . hasSelect ) {
490
- models = await instance . selectFromQuery . execute ( )
491
- }
492
- else {
493
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
494
- }
495
-
496
- const data = await Promise . all ( models . map ( async ( model : DeploymentModel ) => {
497
- const instance = new DeploymentModel ( model )
498
-
499
- const results = await instance . mapWith ( model )
500
-
501
- return new DeploymentModel ( results )
502
- } ) )
503
-
504
- return data
491
+ return await instance . applyGet ( )
505
492
}
506
493
507
494
has ( relation : string ) : DeploymentModel {
Original file line number Diff line number Diff line change @@ -415,7 +415,7 @@ export class ErrorModel {
415
415
. executeTakeFirst ( )
416
416
}
417
417
418
- async get ( ) : Promise < ErrorModel [ ] > {
418
+ async applyGet ( ) : Promise < ErrorModel [ ] > {
419
419
let models
420
420
421
421
if ( this . hasSelect ) {
@@ -436,27 +436,14 @@ export class ErrorModel {
436
436
return data
437
437
}
438
438
439
+ async get ( ) : Promise < ErrorModel [ ] > {
440
+ return await this . applyGet ( )
441
+ }
442
+
439
443
static async get ( ) : Promise < ErrorModel [ ] > {
440
444
const instance = new ErrorModel ( null )
441
445
442
- let models
443
-
444
- if ( instance . hasSelect ) {
445
- models = await instance . selectFromQuery . execute ( )
446
- }
447
- else {
448
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
449
- }
450
-
451
- const data = await Promise . all ( models . map ( async ( model : ErrorModel ) => {
452
- const instance = new ErrorModel ( model )
453
-
454
- const results = await instance . mapWith ( model )
455
-
456
- return new ErrorModel ( results )
457
- } ) )
458
-
459
- return data
446
+ return await instance . applyGet ( )
460
447
}
461
448
462
449
has ( relation : string ) : ErrorModel {
Original file line number Diff line number Diff line change @@ -415,7 +415,7 @@ export class FailedJobModel {
415
415
. executeTakeFirst ( )
416
416
}
417
417
418
- async get ( ) : Promise < FailedJobModel [ ] > {
418
+ async applyGet ( ) : Promise < FailedJobModel [ ] > {
419
419
let models
420
420
421
421
if ( this . hasSelect ) {
@@ -436,27 +436,14 @@ export class FailedJobModel {
436
436
return data
437
437
}
438
438
439
+ async get ( ) : Promise < FailedJobModel [ ] > {
440
+ return await this . applyGet ( )
441
+ }
442
+
439
443
static async get ( ) : Promise < FailedJobModel [ ] > {
440
444
const instance = new FailedJobModel ( null )
441
445
442
- let models
443
-
444
- if ( instance . hasSelect ) {
445
- models = await instance . selectFromQuery . execute ( )
446
- }
447
- else {
448
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
449
- }
450
-
451
- const data = await Promise . all ( models . map ( async ( model : FailedJobModel ) => {
452
- const instance = new FailedJobModel ( model )
453
-
454
- const results = await instance . mapWith ( model )
455
-
456
- return new FailedJobModel ( results )
457
- } ) )
458
-
459
- return data
446
+ return await instance . applyGet ( )
460
447
}
461
448
462
449
has ( relation : string ) : FailedJobModel {
Original file line number Diff line number Diff line change @@ -415,7 +415,7 @@ export class JobModel {
415
415
. executeTakeFirst ( )
416
416
}
417
417
418
- async get ( ) : Promise < JobModel [ ] > {
418
+ async applyGet ( ) : Promise < JobModel [ ] > {
419
419
let models
420
420
421
421
if ( this . hasSelect ) {
@@ -436,27 +436,14 @@ export class JobModel {
436
436
return data
437
437
}
438
438
439
+ async get ( ) : Promise < JobModel [ ] > {
440
+ return await this . applyGet ( )
441
+ }
442
+
439
443
static async get ( ) : Promise < JobModel [ ] > {
440
444
const instance = new JobModel ( null )
441
445
442
- let models
443
-
444
- if ( instance . hasSelect ) {
445
- models = await instance . selectFromQuery . execute ( )
446
- }
447
- else {
448
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
449
- }
450
-
451
- const data = await Promise . all ( models . map ( async ( model : JobModel ) => {
452
- const instance = new JobModel ( model )
453
-
454
- const results = await instance . mapWith ( model )
455
-
456
- return new JobModel ( results )
457
- } ) )
458
-
459
- return data
446
+ return await instance . applyGet ( )
460
447
}
461
448
462
449
has ( relation : string ) : JobModel {
Original file line number Diff line number Diff line change @@ -473,7 +473,7 @@ export class PaymentMethodModel {
473
473
. executeTakeFirst ( )
474
474
}
475
475
476
- async get ( ) : Promise < PaymentMethodModel [ ] > {
476
+ async applyGet ( ) : Promise < PaymentMethodModel [ ] > {
477
477
let models
478
478
479
479
if ( this . hasSelect ) {
@@ -494,27 +494,14 @@ export class PaymentMethodModel {
494
494
return data
495
495
}
496
496
497
+ async get ( ) : Promise < PaymentMethodModel [ ] > {
498
+ return await this . applyGet ( )
499
+ }
500
+
497
501
static async get ( ) : Promise < PaymentMethodModel [ ] > {
498
502
const instance = new PaymentMethodModel ( null )
499
503
500
- let models
501
-
502
- if ( instance . hasSelect ) {
503
- models = await instance . selectFromQuery . execute ( )
504
- }
505
- else {
506
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
507
- }
508
-
509
- const data = await Promise . all ( models . map ( async ( model : PaymentMethodModel ) => {
510
- const instance = new PaymentMethodModel ( model )
511
-
512
- const results = await instance . mapWith ( model )
513
-
514
- return new PaymentMethodModel ( results )
515
- } ) )
516
-
517
- return data
504
+ return await instance . applyGet ( )
518
505
}
519
506
520
507
has ( relation : string ) : PaymentMethodModel {
Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ export class PostModel {
405
405
. executeTakeFirst ( )
406
406
}
407
407
408
- async get ( ) : Promise < PostModel [ ] > {
408
+ async applyGet ( ) : Promise < PostModel [ ] > {
409
409
let models
410
410
411
411
if ( this . hasSelect ) {
@@ -426,27 +426,14 @@ export class PostModel {
426
426
return data
427
427
}
428
428
429
+ async get ( ) : Promise < PostModel [ ] > {
430
+ return await this . applyGet ( )
431
+ }
432
+
429
433
static async get ( ) : Promise < PostModel [ ] > {
430
434
const instance = new PostModel ( null )
431
435
432
- let models
433
-
434
- if ( instance . hasSelect ) {
435
- models = await instance . selectFromQuery . execute ( )
436
- }
437
- else {
438
- models = await instance . selectFromQuery . selectAll ( ) . execute ( )
439
- }
440
-
441
- const data = await Promise . all ( models . map ( async ( model : PostModel ) => {
442
- const instance = new PostModel ( model )
443
-
444
- const results = await instance . mapWith ( model )
445
-
446
- return new PostModel ( results )
447
- } ) )
448
-
449
- return data
436
+ return await instance . applyGet ( )
450
437
}
451
438
452
439
has ( relation : string ) : PostModel {
You can’t perform that action at this time.
0 commit comments