Skip to content

Commit 9b04cee

Browse files
chore: wip
1 parent 9989739 commit 9b04cee

35 files changed

+39
-477
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ export class BaseOrm<T, C, J> {
2424
this.withRelations = []
2525
}
2626

27-
select(params: (keyof J)[] | RawBuilder<string> | string): this {
27+
applySelect(params: (keyof J)[] | RawBuilder<string> | string): this {
2828
this.selectFromQuery = this.selectFromQuery.select(params)
2929

3030
this.hasSelect = true
3131

3232
return this
3333
}
3434

35+
select(params: (keyof J)[] | RawBuilder<string> | string): this {
36+
return this.applySelect(params)
37+
}
38+
3539
// The protected helper method that does the actual work
3640
protected async applyFind(id: number): Promise<T | undefined> {
3741
const model = await DB.instance.selectFrom(this.tableName)

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,24 +1067,11 @@ export async function generateModelString(
10671067
wasChanged(column?: keyof ${modelName}JsonResponse): boolean {
10681068
return this.hasSaved && this.isDirty(column)
10691069
}
1070-
1071-
select(params: (keyof ${modelName}JsonResponse)[] | RawBuilder<string> | string): ${modelName}Model {
1072-
this.selectFromQuery = this.selectFromQuery.select(params)
1073-
1074-
this.hasSelect = true
1075-
1076-
return this
1077-
}
10781070
10791071
static select(params: (keyof ${modelName}JsonResponse)[] | RawBuilder<string> | string): ${modelName}Model {
10801072
const instance = new ${modelName}Model(undefined)
10811073
1082-
// Initialize a query with the table name and selected fields
1083-
instance.selectFromQuery = instance.selectFromQuery.select(params)
1084-
1085-
instance.hasSelect = true
1086-
1087-
return instance
1074+
return instance.applySelect(params)
10881075
}
10891076
10901077
// Method to find a ${modelName} by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,10 @@ export class AccessTokenModel extends BaseOrm<AccessTokenModel, PersonalAccessTo
293293
return this.hasSaved && this.isDirty(column)
294294
}
295295

296-
select(params: (keyof AccessTokenJsonResponse)[] | RawBuilder<string> | string): AccessTokenModel {
297-
this.selectFromQuery = this.selectFromQuery.select(params)
298-
299-
this.hasSelect = true
300-
301-
return this
302-
}
303-
304296
static select(params: (keyof AccessTokenJsonResponse)[] | RawBuilder<string> | string): AccessTokenModel {
305297
const instance = new AccessTokenModel(undefined)
306298

307-
// Initialize a query with the table name and selected fields
308-
instance.selectFromQuery = instance.selectFromQuery.select(params)
309-
310-
instance.hasSelect = true
311-
312-
return instance
299+
return instance.applySelect(params)
313300
}
314301

315302
// Method to find a AccessToken by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,23 +333,10 @@ export class CouponModel extends BaseOrm<CouponModel, CouponsTable, CouponJsonRe
333333
return this.hasSaved && this.isDirty(column)
334334
}
335335

336-
select(params: (keyof CouponJsonResponse)[] | RawBuilder<string> | string): CouponModel {
337-
this.selectFromQuery = this.selectFromQuery.select(params)
338-
339-
this.hasSelect = true
340-
341-
return this
342-
}
343-
344336
static select(params: (keyof CouponJsonResponse)[] | RawBuilder<string> | string): CouponModel {
345337
const instance = new CouponModel(undefined)
346338

347-
// Initialize a query with the table name and selected fields
348-
instance.selectFromQuery = instance.selectFromQuery.select(params)
349-
350-
instance.hasSelect = true
351-
352-
return instance
339+
return instance.applySelect(params)
353340
}
354341

355342
// Method to find a Coupon by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,10 @@ export class CustomerModel extends BaseOrm<CustomerModel, CustomersTable, Custom
278278
return this.hasSaved && this.isDirty(column)
279279
}
280280

281-
select(params: (keyof CustomerJsonResponse)[] | RawBuilder<string> | string): CustomerModel {
282-
this.selectFromQuery = this.selectFromQuery.select(params)
283-
284-
this.hasSelect = true
285-
286-
return this
287-
}
288-
289281
static select(params: (keyof CustomerJsonResponse)[] | RawBuilder<string> | string): CustomerModel {
290282
const instance = new CustomerModel(undefined)
291283

292-
// Initialize a query with the table name and selected fields
293-
instance.selectFromQuery = instance.selectFromQuery.select(params)
294-
295-
instance.hasSelect = true
296-
297-
return instance
284+
return instance.applySelect(params)
298285
}
299286

300287
// Method to find a Customer by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,10 @@ export class DeploymentModel extends BaseOrm<DeploymentModel, DeploymentsTable,
263263
return this.hasSaved && this.isDirty(column)
264264
}
265265

266-
select(params: (keyof DeploymentJsonResponse)[] | RawBuilder<string> | string): DeploymentModel {
267-
this.selectFromQuery = this.selectFromQuery.select(params)
268-
269-
this.hasSelect = true
270-
271-
return this
272-
}
273-
274266
static select(params: (keyof DeploymentJsonResponse)[] | RawBuilder<string> | string): DeploymentModel {
275267
const instance = new DeploymentModel(undefined)
276268

277-
// Initialize a query with the table name and selected fields
278-
instance.selectFromQuery = instance.selectFromQuery.select(params)
279-
280-
instance.hasSelect = true
281-
282-
return instance
269+
return instance.applySelect(params)
283270
}
284271

285272
// Method to find a Deployment by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,10 @@ export class ErrorModel extends BaseOrm<ErrorModel, ErrorsTable, ErrorJsonRespon
223223
return this.hasSaved && this.isDirty(column)
224224
}
225225

226-
select(params: (keyof ErrorJsonResponse)[] | RawBuilder<string> | string): ErrorModel {
227-
this.selectFromQuery = this.selectFromQuery.select(params)
228-
229-
this.hasSelect = true
230-
231-
return this
232-
}
233-
234226
static select(params: (keyof ErrorJsonResponse)[] | RawBuilder<string> | string): ErrorModel {
235227
const instance = new ErrorModel(undefined)
236228

237-
// Initialize a query with the table name and selected fields
238-
instance.selectFromQuery = instance.selectFromQuery.select(params)
239-
240-
instance.hasSelect = true
241-
242-
return instance
229+
return instance.applySelect(params)
243230
}
244231

245232
// Method to find a Error by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,10 @@ export class FailedJobModel extends BaseOrm<FailedJobModel, FailedJobsTable, Fai
223223
return this.hasSaved && this.isDirty(column)
224224
}
225225

226-
select(params: (keyof FailedJobJsonResponse)[] | RawBuilder<string> | string): FailedJobModel {
227-
this.selectFromQuery = this.selectFromQuery.select(params)
228-
229-
this.hasSelect = true
230-
231-
return this
232-
}
233-
234226
static select(params: (keyof FailedJobJsonResponse)[] | RawBuilder<string> | string): FailedJobModel {
235227
const instance = new FailedJobModel(undefined)
236228

237-
// Initialize a query with the table name and selected fields
238-
instance.selectFromQuery = instance.selectFromQuery.select(params)
239-
240-
instance.hasSelect = true
241-
242-
return instance
229+
return instance.applySelect(params)
243230
}
244231

245232
// Method to find a FailedJob by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -342,23 +342,10 @@ export class GiftCardModel extends BaseOrm<GiftCardModel, GiftCardsTable, GiftCa
342342
return this.hasSaved && this.isDirty(column)
343343
}
344344

345-
select(params: (keyof GiftCardJsonResponse)[] | RawBuilder<string> | string): GiftCardModel {
346-
this.selectFromQuery = this.selectFromQuery.select(params)
347-
348-
this.hasSelect = true
349-
350-
return this
351-
}
352-
353345
static select(params: (keyof GiftCardJsonResponse)[] | RawBuilder<string> | string): GiftCardModel {
354346
const instance = new GiftCardModel(undefined)
355347

356-
// Initialize a query with the table name and selected fields
357-
instance.selectFromQuery = instance.selectFromQuery.select(params)
358-
359-
instance.hasSelect = true
360-
361-
return instance
348+
return instance.applySelect(params)
362349
}
363350

364351
// Method to find a GiftCard by ID

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,10 @@ export class JobModel extends BaseOrm<JobModel, JobsTable, JobJsonResponse> {
223223
return this.hasSaved && this.isDirty(column)
224224
}
225225

226-
select(params: (keyof JobJsonResponse)[] | RawBuilder<string> | string): JobModel {
227-
this.selectFromQuery = this.selectFromQuery.select(params)
228-
229-
this.hasSelect = true
230-
231-
return this
232-
}
233-
234226
static select(params: (keyof JobJsonResponse)[] | RawBuilder<string> | string): JobModel {
235227
const instance = new JobModel(undefined)
236228

237-
// Initialize a query with the table name and selected fields
238-
instance.selectFromQuery = instance.selectFromQuery.select(params)
239-
240-
instance.hasSelect = true
241-
242-
return instance
229+
return instance.applySelect(params)
243230
}
244231

245232
// Method to find a Job by ID

0 commit comments

Comments
 (0)