File tree 18 files changed +216
-144
lines changed
18 files changed +216
-144
lines changed Original file line number Diff line number Diff line change @@ -997,26 +997,30 @@ export async function generateModelString(
997
997
return await instance.applyFind(id)
998
998
}
999
999
1000
- async first(): Promise<${ modelName } Model | undefined> {
1001
- return await ${ modelName } Model.first()
1002
- }
1003
-
1004
- static async first(): Promise<${ modelName } Model | undefined> {
1000
+ async applyFirst(): Promise<${ modelName } Model | undefined> {
1005
1001
const model = await DB.instance.selectFrom('${ tableName } ')
1006
1002
.selectAll()
1007
1003
.executeTakeFirst()
1008
1004
1009
1005
if (! model)
1010
1006
return undefined
1011
1007
1012
- const instance = new ${ modelName } Model(null)
1013
-
1014
- const result = await instance.mapWith(model)
1008
+ const result = await this.mapWith(model)
1015
1009
1016
1010
const data = new ${ modelName } Model(result as ${ modelName } Type)
1017
1011
1018
1012
return data
1019
1013
}
1014
+
1015
+ async first(): Promise<${ modelName } Model | undefined> {
1016
+ return await this.first()
1017
+ }
1018
+
1019
+ static async first(): Promise<${ modelName } Model | undefined> {
1020
+ const instance = new ${ modelName } Model(null)
1021
+
1022
+ return await instance.first()
1023
+ }
1020
1024
1021
1025
async firstOrFail(): Promise<${ modelName } Model | undefined> {
1022
1026
return await ${ modelName } Model.firstOrFail()
Original file line number Diff line number Diff line change @@ -228,27 +228,31 @@ export class AccessTokenModel {
228
228
return await instance . applyFind ( id )
229
229
}
230
230
231
- async first ( ) : Promise < AccessTokenModel | undefined > {
232
- return await AccessTokenModel . first ( )
233
- }
234
-
235
- static async first ( ) : Promise < AccessTokenModel | undefined > {
231
+ async applyFirst ( ) : Promise < AccessTokenModel | undefined > {
236
232
const model = await DB . instance . selectFrom ( 'personal_access_tokens' )
237
233
. selectAll ( )
238
234
. executeTakeFirst ( )
239
235
240
236
if ( ! model )
241
237
return undefined
242
238
243
- const instance = new AccessTokenModel ( null )
244
-
245
- const result = await instance . mapWith ( model )
239
+ const result = await this . mapWith ( model )
246
240
247
241
const data = new AccessTokenModel ( result as AccessTokenType )
248
242
249
243
return data
250
244
}
251
245
246
+ async first ( ) : Promise < AccessTokenModel | undefined > {
247
+ return await this . first ( )
248
+ }
249
+
250
+ static async first ( ) : Promise < AccessTokenModel | undefined > {
251
+ const instance = new AccessTokenModel ( null )
252
+
253
+ return await instance . first ( )
254
+ }
255
+
252
256
async firstOrFail ( ) : Promise < AccessTokenModel | undefined > {
253
257
return await AccessTokenModel . firstOrFail ( )
254
258
}
Original file line number Diff line number Diff line change @@ -243,27 +243,31 @@ export class ActivityModel {
243
243
return await instance . applyFind ( id )
244
244
}
245
245
246
- async first ( ) : Promise < ActivityModel | undefined > {
247
- return await ActivityModel . first ( )
248
- }
249
-
250
- static async first ( ) : Promise < ActivityModel | undefined > {
246
+ async applyFirst ( ) : Promise < ActivityModel | undefined > {
251
247
const model = await DB . instance . selectFrom ( 'activities' )
252
248
. selectAll ( )
253
249
. executeTakeFirst ( )
254
250
255
251
if ( ! model )
256
252
return undefined
257
253
258
- const instance = new ActivityModel ( null )
259
-
260
- const result = await instance . mapWith ( model )
254
+ const result = await this . mapWith ( model )
261
255
262
256
const data = new ActivityModel ( result as ActivityType )
263
257
264
258
return data
265
259
}
266
260
261
+ async first ( ) : Promise < ActivityModel | undefined > {
262
+ return await this . first ( )
263
+ }
264
+
265
+ static async first ( ) : Promise < ActivityModel | undefined > {
266
+ const instance = new ActivityModel ( null )
267
+
268
+ return await instance . first ( )
269
+ }
270
+
267
271
async firstOrFail ( ) : Promise < ActivityModel | undefined > {
268
272
return await ActivityModel . firstOrFail ( )
269
273
}
Original file line number Diff line number Diff line change @@ -265,27 +265,31 @@ export class DeploymentModel {
265
265
return await instance . applyFind ( id )
266
266
}
267
267
268
- async first ( ) : Promise < DeploymentModel | undefined > {
269
- return await DeploymentModel . first ( )
270
- }
271
-
272
- static async first ( ) : Promise < DeploymentModel | undefined > {
268
+ async applyFirst ( ) : Promise < DeploymentModel | undefined > {
273
269
const model = await DB . instance . selectFrom ( 'deployments' )
274
270
. selectAll ( )
275
271
. executeTakeFirst ( )
276
272
277
273
if ( ! model )
278
274
return undefined
279
275
280
- const instance = new DeploymentModel ( null )
281
-
282
- const result = await instance . mapWith ( model )
276
+ const result = await this . mapWith ( model )
283
277
284
278
const data = new DeploymentModel ( result as DeploymentType )
285
279
286
280
return data
287
281
}
288
282
283
+ async first ( ) : Promise < DeploymentModel | undefined > {
284
+ return await this . first ( )
285
+ }
286
+
287
+ static async first ( ) : Promise < DeploymentModel | undefined > {
288
+ const instance = new DeploymentModel ( null )
289
+
290
+ return await instance . first ( )
291
+ }
292
+
289
293
async firstOrFail ( ) : Promise < DeploymentModel | undefined > {
290
294
return await DeploymentModel . firstOrFail ( )
291
295
}
Original file line number Diff line number Diff line change @@ -224,27 +224,31 @@ export class ErrorModel {
224
224
return await instance . applyFind ( id )
225
225
}
226
226
227
- async first ( ) : Promise < ErrorModel | undefined > {
228
- return await ErrorModel . first ( )
229
- }
230
-
231
- static async first ( ) : Promise < ErrorModel | undefined > {
227
+ async applyFirst ( ) : Promise < ErrorModel | undefined > {
232
228
const model = await DB . instance . selectFrom ( 'errors' )
233
229
. selectAll ( )
234
230
. executeTakeFirst ( )
235
231
236
232
if ( ! model )
237
233
return undefined
238
234
239
- const instance = new ErrorModel ( null )
240
-
241
- const result = await instance . mapWith ( model )
235
+ const result = await this . mapWith ( model )
242
236
243
237
const data = new ErrorModel ( result as ErrorType )
244
238
245
239
return data
246
240
}
247
241
242
+ async first ( ) : Promise < ErrorModel | undefined > {
243
+ return await this . first ( )
244
+ }
245
+
246
+ static async first ( ) : Promise < ErrorModel | undefined > {
247
+ const instance = new ErrorModel ( null )
248
+
249
+ return await instance . first ( )
250
+ }
251
+
248
252
async firstOrFail ( ) : Promise < ErrorModel | undefined > {
249
253
return await ErrorModel . firstOrFail ( )
250
254
}
Original file line number Diff line number Diff line change @@ -224,27 +224,31 @@ export class FailedJobModel {
224
224
return await instance . applyFind ( id )
225
225
}
226
226
227
- async first ( ) : Promise < FailedJobModel | undefined > {
228
- return await FailedJobModel . first ( )
229
- }
230
-
231
- static async first ( ) : Promise < FailedJobModel | undefined > {
227
+ async applyFirst ( ) : Promise < FailedJobModel | undefined > {
232
228
const model = await DB . instance . selectFrom ( 'failed_jobs' )
233
229
. selectAll ( )
234
230
. executeTakeFirst ( )
235
231
236
232
if ( ! model )
237
233
return undefined
238
234
239
- const instance = new FailedJobModel ( null )
240
-
241
- const result = await instance . mapWith ( model )
235
+ const result = await this . mapWith ( model )
242
236
243
237
const data = new FailedJobModel ( result as FailedJobType )
244
238
245
239
return data
246
240
}
247
241
242
+ async first ( ) : Promise < FailedJobModel | undefined > {
243
+ return await this . first ( )
244
+ }
245
+
246
+ static async first ( ) : Promise < FailedJobModel | undefined > {
247
+ const instance = new FailedJobModel ( null )
248
+
249
+ return await instance . first ( )
250
+ }
251
+
248
252
async firstOrFail ( ) : Promise < FailedJobModel | undefined > {
249
253
return await FailedJobModel . firstOrFail ( )
250
254
}
Original file line number Diff line number Diff line change @@ -224,27 +224,31 @@ export class JobModel {
224
224
return await instance . applyFind ( id )
225
225
}
226
226
227
- async first ( ) : Promise < JobModel | undefined > {
228
- return await JobModel . first ( )
229
- }
230
-
231
- static async first ( ) : Promise < JobModel | undefined > {
227
+ async applyFirst ( ) : Promise < JobModel | undefined > {
232
228
const model = await DB . instance . selectFrom ( 'jobs' )
233
229
. selectAll ( )
234
230
. executeTakeFirst ( )
235
231
236
232
if ( ! model )
237
233
return undefined
238
234
239
- const instance = new JobModel ( null )
240
-
241
- const result = await instance . mapWith ( model )
235
+ const result = await this . mapWith ( model )
242
236
243
237
const data = new JobModel ( result as JobType )
244
238
245
239
return data
246
240
}
247
241
242
+ async first ( ) : Promise < JobModel | undefined > {
243
+ return await this . first ( )
244
+ }
245
+
246
+ static async first ( ) : Promise < JobModel | undefined > {
247
+ const instance = new JobModel ( null )
248
+
249
+ return await instance . first ( )
250
+ }
251
+
248
252
async firstOrFail ( ) : Promise < JobModel | undefined > {
249
253
return await JobModel . firstOrFail ( )
250
254
}
Original file line number Diff line number Diff line change @@ -274,27 +274,31 @@ export class PaymentMethodModel {
274
274
return await instance . applyFind ( id )
275
275
}
276
276
277
- async first ( ) : Promise < PaymentMethodModel | undefined > {
278
- return await PaymentMethodModel . first ( )
279
- }
280
-
281
- static async first ( ) : Promise < PaymentMethodModel | undefined > {
277
+ async applyFirst ( ) : Promise < PaymentMethodModel | undefined > {
282
278
const model = await DB . instance . selectFrom ( 'payment_methods' )
283
279
. selectAll ( )
284
280
. executeTakeFirst ( )
285
281
286
282
if ( ! model )
287
283
return undefined
288
284
289
- const instance = new PaymentMethodModel ( null )
290
-
291
- const result = await instance . mapWith ( model )
285
+ const result = await this . mapWith ( model )
292
286
293
287
const data = new PaymentMethodModel ( result as PaymentMethodType )
294
288
295
289
return data
296
290
}
297
291
292
+ async first ( ) : Promise < PaymentMethodModel | undefined > {
293
+ return await this . first ( )
294
+ }
295
+
296
+ static async first ( ) : Promise < PaymentMethodModel | undefined > {
297
+ const instance = new PaymentMethodModel ( null )
298
+
299
+ return await instance . first ( )
300
+ }
301
+
298
302
async firstOrFail ( ) : Promise < PaymentMethodModel | undefined > {
299
303
return await PaymentMethodModel . firstOrFail ( )
300
304
}
Original file line number Diff line number Diff line change @@ -210,27 +210,31 @@ export class PostModel {
210
210
return await instance . applyFind ( id )
211
211
}
212
212
213
- async first ( ) : Promise < PostModel | undefined > {
214
- return await PostModel . first ( )
215
- }
216
-
217
- static async first ( ) : Promise < PostModel | undefined > {
213
+ async applyFirst ( ) : Promise < PostModel | undefined > {
218
214
const model = await DB . instance . selectFrom ( 'posts' )
219
215
. selectAll ( )
220
216
. executeTakeFirst ( )
221
217
222
218
if ( ! model )
223
219
return undefined
224
220
225
- const instance = new PostModel ( null )
226
-
227
- const result = await instance . mapWith ( model )
221
+ const result = await this . mapWith ( model )
228
222
229
223
const data = new PostModel ( result as PostType )
230
224
231
225
return data
232
226
}
233
227
228
+ async first ( ) : Promise < PostModel | undefined > {
229
+ return await this . first ( )
230
+ }
231
+
232
+ static async first ( ) : Promise < PostModel | undefined > {
233
+ const instance = new PostModel ( null )
234
+
235
+ return await instance . first ( )
236
+ }
237
+
234
238
async firstOrFail ( ) : Promise < PostModel | undefined > {
235
239
return await PostModel . firstOrFail ( )
236
240
}
Original file line number Diff line number Diff line change @@ -252,27 +252,31 @@ export class ProductModel {
252
252
return await instance . applyFind ( id )
253
253
}
254
254
255
- async first ( ) : Promise < ProductModel | undefined > {
256
- return await ProductModel . first ( )
257
- }
258
-
259
- static async first ( ) : Promise < ProductModel | undefined > {
255
+ async applyFirst ( ) : Promise < ProductModel | undefined > {
260
256
const model = await DB . instance . selectFrom ( 'products' )
261
257
. selectAll ( )
262
258
. executeTakeFirst ( )
263
259
264
260
if ( ! model )
265
261
return undefined
266
262
267
- const instance = new ProductModel ( null )
268
-
269
- const result = await instance . mapWith ( model )
263
+ const result = await this . mapWith ( model )
270
264
271
265
const data = new ProductModel ( result as ProductType )
272
266
273
267
return data
274
268
}
275
269
270
+ async first ( ) : Promise < ProductModel | undefined > {
271
+ return await this . first ( )
272
+ }
273
+
274
+ static async first ( ) : Promise < ProductModel | undefined > {
275
+ const instance = new ProductModel ( null )
276
+
277
+ return await instance . first ( )
278
+ }
279
+
276
280
async firstOrFail ( ) : Promise < ProductModel | undefined > {
277
281
return await ProductModel . firstOrFail ( )
278
282
}
You can’t perform that action at this time.
0 commit comments