Skip to content

Commit 851275b

Browse files
chore: wip
1 parent 55eeda8 commit 851275b

30 files changed

+228
-30
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,14 @@ export async function generateModelString(
13281328
}
13291329
13301330
async pluck<K extends keyof ${modelName}Model>(field: K): Promise<${modelName}Model[K][]> {
1331-
return ${modelName}Model.pluck(field)
1331+
if (this.hasSelect) {
1332+
const model = await this.selectFromQuery.execute()
1333+
return model.map((modelItem: ${modelName}Model) => modelItem[field])
1334+
}
1335+
1336+
const model = await this.selectFromQuery.selectAll().execute()
1337+
1338+
return model.map((modelItem: ${modelName}Model) => modelItem[field])
13321339
}
13331340
13341341
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,14 @@ export class AccessTokenModel {
545545
}
546546

547547
async pluck<K extends keyof AccessTokenModel>(field: K): Promise<AccessTokenModel[K][]> {
548-
return AccessTokenModel.pluck(field)
548+
if (this.hasSelect) {
549+
const model = await this.selectFromQuery.execute()
550+
return model.map((modelItem: AccessTokenModel) => modelItem[field])
551+
}
552+
553+
const model = await this.selectFromQuery.selectAll().execute()
554+
555+
return model.map((modelItem: AccessTokenModel) => modelItem[field])
549556
}
550557

551558
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,14 @@ export class CouponModel {
585585
}
586586

587587
async pluck<K extends keyof CouponModel>(field: K): Promise<CouponModel[K][]> {
588-
return CouponModel.pluck(field)
588+
if (this.hasSelect) {
589+
const model = await this.selectFromQuery.execute()
590+
return model.map((modelItem: CouponModel) => modelItem[field])
591+
}
592+
593+
const model = await this.selectFromQuery.selectAll().execute()
594+
595+
return model.map((modelItem: CouponModel) => modelItem[field])
589596
}
590597

591598
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,14 @@ export class CustomerModel {
530530
}
531531

532532
async pluck<K extends keyof CustomerModel>(field: K): Promise<CustomerModel[K][]> {
533-
return CustomerModel.pluck(field)
533+
if (this.hasSelect) {
534+
const model = await this.selectFromQuery.execute()
535+
return model.map((modelItem: CustomerModel) => modelItem[field])
536+
}
537+
538+
const model = await this.selectFromQuery.selectAll().execute()
539+
540+
return model.map((modelItem: CustomerModel) => modelItem[field])
534541
}
535542

536543
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,14 @@ export class DeploymentModel {
514514
}
515515

516516
async pluck<K extends keyof DeploymentModel>(field: K): Promise<DeploymentModel[K][]> {
517-
return DeploymentModel.pluck(field)
517+
if (this.hasSelect) {
518+
const model = await this.selectFromQuery.execute()
519+
return model.map((modelItem: DeploymentModel) => modelItem[field])
520+
}
521+
522+
const model = await this.selectFromQuery.selectAll().execute()
523+
524+
return model.map((modelItem: DeploymentModel) => modelItem[field])
518525
}
519526

520527
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,14 @@ export class ErrorModel {
473473
}
474474

475475
async pluck<K extends keyof ErrorModel>(field: K): Promise<ErrorModel[K][]> {
476-
return ErrorModel.pluck(field)
476+
if (this.hasSelect) {
477+
const model = await this.selectFromQuery.execute()
478+
return model.map((modelItem: ErrorModel) => modelItem[field])
479+
}
480+
481+
const model = await this.selectFromQuery.selectAll().execute()
482+
483+
return model.map((modelItem: ErrorModel) => modelItem[field])
477484
}
478485

479486
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,14 @@ export class FailedJobModel {
473473
}
474474

475475
async pluck<K extends keyof FailedJobModel>(field: K): Promise<FailedJobModel[K][]> {
476-
return FailedJobModel.pluck(field)
476+
if (this.hasSelect) {
477+
const model = await this.selectFromQuery.execute()
478+
return model.map((modelItem: FailedJobModel) => modelItem[field])
479+
}
480+
481+
const model = await this.selectFromQuery.selectAll().execute()
482+
483+
return model.map((modelItem: FailedJobModel) => modelItem[field])
477484
}
478485

479486
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,14 @@ export class GiftCardModel {
594594
}
595595

596596
async pluck<K extends keyof GiftCardModel>(field: K): Promise<GiftCardModel[K][]> {
597-
return GiftCardModel.pluck(field)
597+
if (this.hasSelect) {
598+
const model = await this.selectFromQuery.execute()
599+
return model.map((modelItem: GiftCardModel) => modelItem[field])
600+
}
601+
602+
const model = await this.selectFromQuery.selectAll().execute()
603+
604+
return model.map((modelItem: GiftCardModel) => modelItem[field])
598605
}
599606

600607
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,14 @@ export class JobModel {
473473
}
474474

475475
async pluck<K extends keyof JobModel>(field: K): Promise<JobModel[K][]> {
476-
return JobModel.pluck(field)
476+
if (this.hasSelect) {
477+
const model = await this.selectFromQuery.execute()
478+
return model.map((modelItem: JobModel) => modelItem[field])
479+
}
480+
481+
const model = await this.selectFromQuery.selectAll().execute()
482+
483+
return model.map((modelItem: JobModel) => modelItem[field])
477484
}
478485

479486
static async count(): Promise<number> {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,14 @@ export class LoyaltyPointModel {
502502
}
503503

504504
async pluck<K extends keyof LoyaltyPointModel>(field: K): Promise<LoyaltyPointModel[K][]> {
505-
return LoyaltyPointModel.pluck(field)
505+
if (this.hasSelect) {
506+
const model = await this.selectFromQuery.execute()
507+
return model.map((modelItem: LoyaltyPointModel) => modelItem[field])
508+
}
509+
510+
const model = await this.selectFromQuery.selectAll().execute()
511+
512+
return model.map((modelItem: LoyaltyPointModel) => modelItem[field])
506513
}
507514

508515
static async count(): Promise<number> {

0 commit comments

Comments
 (0)