Skip to content

Commit 2caf129

Browse files
chore: wip
1 parent 6cb1ebc commit 2caf129

File tree

16 files changed

+151
-0
lines changed

16 files changed

+151
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,13 +1706,15 @@ export async function generateModelString(
17061706
private fillable = ${fillable}
17071707
private softDeletes = ${useSoftDeletes}
17081708
protected selectFromQuery: any
1709+
protected withRelations: string[]
17091710
protected updateFromQuery: any
17101711
protected deleteFromQuery: any
17111712
protected hasSelect: boolean
17121713
${declareFields}
17131714
constructor(${formattedModelName}: Partial<${modelName}Type> | null) {
17141715
${constructorFields}
17151716
1717+
this.withRelations = []
17161718
this.selectFromQuery = db.selectFrom('${tableName}')
17171719
this.updateFromQuery = db.updateTable('${tableName}')
17181720
this.deleteFromQuery = db.deleteFrom('${tableName}')
@@ -1958,6 +1960,8 @@ export async function generateModelString(
19581960
19591961
// Method to remove a ${modelName}
19601962
static async remove(id: number): Promise<any> {
1963+
const instance = new ${modelName}Model(null)
1964+
19611965
${mittDeleteStaticFindStatement}
19621966
19631967
${instanceSoftDeleteStatementsUpdateFrom}
@@ -2158,6 +2162,12 @@ export async function generateModelString(
21582162
return data
21592163
}
21602164
2165+
with(relations: string[]): ${modelName}Model {
2166+
this.withRelations = relations
2167+
2168+
return this
2169+
}
2170+
21612171
async last(): Promise<${modelName}Type | undefined> {
21622172
return await db.selectFrom('${tableName}')
21632173
.selectAll()

storage/framework/core/payments/src/billable/transaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Transaction, type TransactionModel } from '../../../../orm/src/models/T
44

55
export interface ManageTransaction {
66
store: (user: UserModel, productId: number) => Promise<TransactionModel>
7+
list: (user: UserModel) => Promise<TransactionModel[]>
78
}
89

910
export const manageTransaction: ManageTransaction = (() => {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class AccessTokenModel {
5151
private fillable = ['name', 'token', 'plain_text_token', 'abilities', 'uuid', 'team_id']
5252
private softDeletes = false
5353
protected selectFromQuery: any
54+
protected withRelations: string[]
5455
protected updateFromQuery: any
5556
protected deleteFromQuery: any
5657
protected hasSelect: boolean
@@ -74,6 +75,7 @@ export class AccessTokenModel {
7475

7576
this.updated_at = accesstoken?.updated_at
7677

78+
this.withRelations = []
7779
this.selectFromQuery = db.selectFrom('personal_access_tokens')
7880
this.updateFromQuery = db.updateTable('personal_access_tokens')
7981
this.deleteFromQuery = db.deleteFrom('personal_access_tokens')
@@ -271,6 +273,8 @@ export class AccessTokenModel {
271273

272274
// Method to remove a AccessToken
273275
static async remove(id: number): Promise<any> {
276+
const instance = new AccessTokenModel(null)
277+
274278
return await db.deleteFrom('personal_access_tokens')
275279
.where('id', '=', id)
276280
.execute()
@@ -492,6 +496,12 @@ export class AccessTokenModel {
492496
return data
493497
}
494498

499+
with(relations: string[]): AccessTokenModel {
500+
this.withRelations = relations
501+
502+
return this
503+
}
504+
495505
async last(): Promise<AccessTokenType | undefined> {
496506
return await db.selectFrom('personal_access_tokens')
497507
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class DeploymentModel {
5959
private fillable = ['commit_sha', 'commit_message', 'branch', 'status', 'execution_time', 'deploy_script', 'terminal_output', 'uuid', 'user_id']
6060
private softDeletes = false
6161
protected selectFromQuery: any
62+
protected withRelations: string[]
6263
protected updateFromQuery: any
6364
protected deleteFromQuery: any
6465
protected hasSelect: boolean
@@ -94,6 +95,7 @@ export class DeploymentModel {
9495

9596
this.updated_at = deployment?.updated_at
9697

98+
this.withRelations = []
9799
this.selectFromQuery = db.selectFrom('deployments')
98100
this.updateFromQuery = db.updateTable('deployments')
99101
this.deleteFromQuery = db.deleteFrom('deployments')
@@ -315,6 +317,8 @@ export class DeploymentModel {
315317

316318
// Method to remove a Deployment
317319
static async remove(id: number): Promise<any> {
320+
const instance = new DeploymentModel(null)
321+
318322
return await db.deleteFrom('deployments')
319323
.where('id', '=', id)
320324
.execute()
@@ -566,6 +570,12 @@ export class DeploymentModel {
566570
return data
567571
}
568572

573+
with(relations: string[]): DeploymentModel {
574+
this.withRelations = relations
575+
576+
return this
577+
}
578+
569579
async last(): Promise<DeploymentType | undefined> {
570580
return await db.selectFrom('deployments')
571581
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class ErrorModel {
5151
private fillable = ['type', 'message', 'stack', 'status', 'user_id', 'additional_info', 'uuid']
5252
private softDeletes = false
5353
protected selectFromQuery: any
54+
protected withRelations: string[]
5455
protected updateFromQuery: any
5556
protected deleteFromQuery: any
5657
protected hasSelect: boolean
@@ -78,6 +79,7 @@ export class ErrorModel {
7879

7980
this.updated_at = error?.updated_at
8081

82+
this.withRelations = []
8183
this.selectFromQuery = db.selectFrom('errors')
8284
this.updateFromQuery = db.updateTable('errors')
8385
this.deleteFromQuery = db.deleteFrom('errors')
@@ -275,6 +277,8 @@ export class ErrorModel {
275277

276278
// Method to remove a Error
277279
static async remove(id: number): Promise<any> {
280+
const instance = new ErrorModel(null)
281+
278282
return await db.deleteFrom('errors')
279283
.where('id', '=', id)
280284
.execute()
@@ -512,6 +516,12 @@ export class ErrorModel {
512516
return data
513517
}
514518

519+
with(relations: string[]): ErrorModel {
520+
this.withRelations = relations
521+
522+
return this
523+
}
524+
515525
async last(): Promise<ErrorType | undefined> {
516526
return await db.selectFrom('errors')
517527
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class PaymentMethodModel {
6363
private fillable = ['type', 'last_four', 'brand', 'exp_month', 'exp_year', 'is_default', 'provider_id', 'uuid', 'user_id', 'transaction_id']
6464
private softDeletes = false
6565
protected selectFromQuery: any
66+
protected withRelations: string[]
6667
protected updateFromQuery: any
6768
protected deleteFromQuery: any
6869
protected hasSelect: boolean
@@ -100,6 +101,7 @@ export class PaymentMethodModel {
100101

101102
this.updated_at = paymentmethod?.updated_at
102103

104+
this.withRelations = []
103105
this.selectFromQuery = db.selectFrom('payment_methods')
104106
this.updateFromQuery = db.updateTable('payment_methods')
105107
this.deleteFromQuery = db.deleteFrom('payment_methods')
@@ -331,6 +333,8 @@ export class PaymentMethodModel {
331333

332334
// Method to remove a PaymentMethod
333335
static async remove(id: number): Promise<any> {
336+
const instance = new PaymentMethodModel(null)
337+
334338
return await db.deleteFrom('payment_methods')
335339
.where('id', '=', id)
336340
.execute()
@@ -586,6 +590,12 @@ export class PaymentMethodModel {
586590
return data
587591
}
588592

593+
with(relations: string[]): PaymentMethodModel {
594+
this.withRelations = relations
595+
596+
return this
597+
}
598+
589599
async last(): Promise<PaymentMethodType | undefined> {
590600
return await db.selectFrom('payment_methods')
591601
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class PostModel {
5252
private fillable = ['title', 'body', 'uuid', 'user_id']
5353
private softDeletes = false
5454
protected selectFromQuery: any
55+
protected withRelations: string[]
5556
protected updateFromQuery: any
5657
protected deleteFromQuery: any
5758
protected hasSelect: boolean
@@ -75,6 +76,7 @@ export class PostModel {
7576

7677
this.updated_at = post?.updated_at
7778

79+
this.withRelations = []
7880
this.selectFromQuery = db.selectFrom('posts')
7981
this.updateFromQuery = db.updateTable('posts')
8082
this.deleteFromQuery = db.deleteFrom('posts')
@@ -290,6 +292,8 @@ export class PostModel {
290292

291293
// Method to remove a Post
292294
static async remove(id: number): Promise<any> {
295+
const instance = new PostModel(null)
296+
293297
return await db.deleteFrom('posts')
294298
.where('id', '=', id)
295299
.execute()
@@ -501,6 +505,12 @@ export class PostModel {
501505
return data
502506
}
503507

508+
with(relations: string[]): PostModel {
509+
this.withRelations = relations
510+
511+
return this
512+
}
513+
504514
async last(): Promise<PostType | undefined> {
505515
return await db.selectFrom('posts')
506516
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class ProductModel {
5454
private fillable = ['name', 'description', 'key', 'unit_price', 'status', 'image', 'provider_id', 'uuid']
5555
private softDeletes = false
5656
protected selectFromQuery: any
57+
protected withRelations: string[]
5758
protected updateFromQuery: any
5859
protected deleteFromQuery: any
5960
protected hasSelect: boolean
@@ -85,6 +86,7 @@ export class ProductModel {
8586

8687
this.updated_at = product?.updated_at
8788

89+
this.withRelations = []
8890
this.selectFromQuery = db.selectFrom('products')
8991
this.updateFromQuery = db.updateTable('products')
9092
this.deleteFromQuery = db.deleteFrom('products')
@@ -288,6 +290,8 @@ export class ProductModel {
288290

289291
// Method to remove a Product
290292
static async remove(id: number): Promise<any> {
293+
const instance = new ProductModel(null)
294+
291295
return await db.deleteFrom('products')
292296
.where('id', '=', id)
293297
.execute()
@@ -533,6 +537,12 @@ export class ProductModel {
533537
return data
534538
}
535539

540+
with(relations: string[]): ProductModel {
541+
this.withRelations = relations
542+
543+
return this
544+
}
545+
536546
async last(): Promise<ProductType | undefined> {
537547
return await db.selectFrom('products')
538548
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class ProjectModel {
4949
private fillable = ['name', 'description', 'url', 'status', 'uuid']
5050
private softDeletes = false
5151
protected selectFromQuery: any
52+
protected withRelations: string[]
5253
protected updateFromQuery: any
5354
protected deleteFromQuery: any
5455
protected hasSelect: boolean
@@ -72,6 +73,7 @@ export class ProjectModel {
7273

7374
this.updated_at = project?.updated_at
7475

76+
this.withRelations = []
7577
this.selectFromQuery = db.selectFrom('projects')
7678
this.updateFromQuery = db.updateTable('projects')
7779
this.deleteFromQuery = db.deleteFrom('projects')
@@ -269,6 +271,8 @@ export class ProjectModel {
269271

270272
// Method to remove a Project
271273
static async remove(id: number): Promise<any> {
274+
const instance = new ProjectModel(null)
275+
272276
return await db.deleteFrom('projects')
273277
.where('id', '=', id)
274278
.execute()
@@ -490,6 +494,12 @@ export class ProjectModel {
490494
return data
491495
}
492496

497+
with(relations: string[]): ProjectModel {
498+
this.withRelations = relations
499+
500+
return this
501+
}
502+
493503
async last(): Promise<ProjectType | undefined> {
494504
return await db.selectFrom('projects')
495505
.selectAll()

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class ReleaseModel {
4646
private fillable = ['version', 'uuid']
4747
private softDeletes = false
4848
protected selectFromQuery: any
49+
protected withRelations: string[]
4950
protected updateFromQuery: any
5051
protected deleteFromQuery: any
5152
protected hasSelect: boolean
@@ -63,6 +64,7 @@ export class ReleaseModel {
6364

6465
this.updated_at = release?.updated_at
6566

67+
this.withRelations = []
6668
this.selectFromQuery = db.selectFrom('releases')
6769
this.updateFromQuery = db.updateTable('releases')
6870
this.deleteFromQuery = db.deleteFrom('releases')
@@ -260,6 +262,8 @@ export class ReleaseModel {
260262

261263
// Method to remove a Release
262264
static async remove(id: number): Promise<any> {
265+
const instance = new ReleaseModel(null)
266+
263267
return await db.deleteFrom('releases')
264268
.where('id', '=', id)
265269
.execute()
@@ -457,6 +461,12 @@ export class ReleaseModel {
457461
return data
458462
}
459463

464+
with(relations: string[]): ReleaseModel {
465+
this.withRelations = relations
466+
467+
return this
468+
}
469+
460470
async last(): Promise<ReleaseType | undefined> {
461471
return await db.selectFrom('releases')
462472
.selectAll()

0 commit comments

Comments
 (0)