Skip to content

Commit 84b6044

Browse files
chore: wip
1 parent 256b464 commit 84b6044

File tree

17 files changed

+170
-0
lines changed

17 files changed

+170
-0
lines changed

storage/framework/core/orm/src/generate.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,16 @@ export async function generateModelString(
11331133
return instance
11341134
}
11351135
1136+
static whereExists(callback: (qb: any) => any): ${modelName}Model {
1137+
const instance = new ${modelName}Model(null)
1138+
1139+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
1140+
exists(callback({ exists, selectFrom }))
1141+
)
1142+
1143+
return instance
1144+
}
1145+
11361146
whereHas(
11371147
relation: string,
11381148
callback: (query: SubqueryBuilder) => void

storage/framework/orm/src/models/AccessToken.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ export class AccessTokenModel {
434434
return instance
435435
}
436436

437+
static whereExists(callback: (qb: any) => any): AccessTokenModel {
438+
const instance = new AccessTokenModel(null)
439+
440+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
441+
exists(callback({ exists, selectFrom })),
442+
)
443+
444+
return instance
445+
}
446+
437447
whereHas(
438448
relation: string,
439449
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Deployment.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,16 @@ export class DeploymentModel {
470470
return instance
471471
}
472472

473+
static whereExists(callback: (qb: any) => any): DeploymentModel {
474+
const instance = new DeploymentModel(null)
475+
476+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
477+
exists(callback({ exists, selectFrom })),
478+
)
479+
480+
return instance
481+
}
482+
473483
whereHas(
474484
relation: string,
475485
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Error.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@ export class ErrorModel {
426426
return instance
427427
}
428428

429+
static whereExists(callback: (qb: any) => any): ErrorModel {
430+
const instance = new ErrorModel(null)
431+
432+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
433+
exists(callback({ exists, selectFrom })),
434+
)
435+
436+
return instance
437+
}
438+
429439
whereHas(
430440
relation: string,
431441
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/FailedJob.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@ export class FailedJobModel {
426426
return instance
427427
}
428428

429+
static whereExists(callback: (qb: any) => any): FailedJobModel {
430+
const instance = new FailedJobModel(null)
431+
432+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
433+
exists(callback({ exists, selectFrom })),
434+
)
435+
436+
return instance
437+
}
438+
429439
whereHas(
430440
relation: string,
431441
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Job.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@ export class JobModel {
426426
return instance
427427
}
428428

429+
static whereExists(callback: (qb: any) => any): JobModel {
430+
const instance = new JobModel(null)
431+
432+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
433+
exists(callback({ exists, selectFrom })),
434+
)
435+
436+
return instance
437+
}
438+
429439
whereHas(
430440
relation: string,
431441
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/PaymentMethod.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ export class PaymentMethodModel {
483483
return instance
484484
}
485485

486+
static whereExists(callback: (qb: any) => any): PaymentMethodModel {
487+
const instance = new PaymentMethodModel(null)
488+
489+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
490+
exists(callback({ exists, selectFrom })),
491+
)
492+
493+
return instance
494+
}
495+
486496
whereHas(
487497
relation: string,
488498
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Post.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ export class PostModel {
416416
return instance
417417
}
418418

419+
static whereExists(callback: (qb: any) => any): PostModel {
420+
const instance = new PostModel(null)
421+
422+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
423+
exists(callback({ exists, selectFrom })),
424+
)
425+
426+
return instance
427+
}
428+
419429
whereHas(
420430
relation: string,
421431
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Product.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,16 @@ export class ProductModel {
453453
return instance
454454
}
455455

456+
static whereExists(callback: (qb: any) => any): ProductModel {
457+
const instance = new ProductModel(null)
458+
459+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
460+
exists(callback({ exists, selectFrom })),
461+
)
462+
463+
return instance
464+
}
465+
456466
whereHas(
457467
relation: string,
458468
callback: (query: SubqueryBuilder) => void,

storage/framework/orm/src/models/Project.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,16 @@ export class ProjectModel {
417417
return instance
418418
}
419419

420+
static whereExists(callback: (qb: any) => any): ProjectModel {
421+
const instance = new ProjectModel(null)
422+
423+
instance.selectFromQuery = instance.selectFromQuery.where(({ exists, selectFrom }: any) =>
424+
exists(callback({ exists, selectFrom })),
425+
)
426+
427+
return instance
428+
}
429+
420430
whereHas(
421431
relation: string,
422432
callback: (query: SubqueryBuilder) => void,

0 commit comments

Comments
 (0)