File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -740,9 +740,22 @@ async function generateModelString(
740
740
741
741
if ( typeof observer === 'boolean' ) {
742
742
if ( observer ) {
743
- mittCreateStatement += `emitter.emit('${ formattedModelName } .created', model)`
744
- mittUpdateStatement += `emitter.emit('${ formattedModelName } .updated', model)`
745
- mittDeleteStatement += `emitter.emit('${ formattedModelName } .deleted', model)`
743
+ mittCreateStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .created', model)`
744
+ mittUpdateStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .updated', model)`
745
+ mittDeleteStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .deleted', model)`
746
+ }
747
+ }
748
+
749
+ if ( Array . isArray ( observer ) ) {
750
+ // Iterate through the array and append statements based on its contents
751
+ if ( observer . includes ( 'create' ) ) {
752
+ mittCreateStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .created', model);`
753
+ }
754
+ if ( observer . includes ( 'update' ) ) {
755
+ mittUpdateStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .updated', model);`
756
+ }
757
+ if ( observer . includes ( 'delete' ) ) {
758
+ mittDeleteStatement += `const emitter = mitt()\n emitter.emit('${ formattedModelName } .deleted', model);`
746
759
}
747
760
}
748
761
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ async function configureAws(options?: ConfigureOptions) {
62
62
const defaultRegion = 'us-east-1' // we only support `us-east-1` for now
63
63
const defaultOutputFormat = options ?. output ?? 'json'
64
64
65
- const profile = process . env . AWS_PROFILE ?? options ?. profile
65
+ const profile = process . env . AWS_PROFILE ?? options ?. profile
66
66
const command = profile ? `aws configure --profile ${ profile } ` : `aws configure`
67
67
const input = `${ awsAccessKeyId } \n${ awsSecretAccessKey } \n${ defaultRegion } \n${ defaultOutputFormat } \n`
68
68
Original file line number Diff line number Diff line change @@ -275,6 +275,7 @@ export class UserModel {
275
275
276
276
const model = ( await find ( Number ( result . insertId ) ) ) as UserModel
277
277
278
+ const emitter = mitt ( )
278
279
emitter . emit ( 'user.created' , model )
279
280
280
281
return model
@@ -288,6 +289,7 @@ export class UserModel {
288
289
289
290
await db . deleteFrom ( 'users' ) . where ( 'id' , '=' , id ) . execute ( )
290
291
292
+ const emitter = mitt ( )
291
293
emitter . emit ( 'user.deleted' , model )
292
294
}
293
295
@@ -452,6 +454,7 @@ export class UserModel {
452
454
453
455
const model = this . find ( Number ( this . id ) )
454
456
457
+ const emitter = mitt ( )
455
458
emitter . emit ( 'user.updated' , model )
456
459
457
460
return model
@@ -479,6 +482,7 @@ export class UserModel {
479
482
480
483
await db . deleteFrom ( 'users' ) . where ( 'id' , '=' , this . id ) . execute ( )
481
484
485
+ const emitter = mitt ( )
482
486
emitter . emit ( 'user.deleted' , this )
483
487
}
484
488
You can’t perform that action at this time.
0 commit comments