File tree Expand file tree Collapse file tree 17 files changed +205
-1
lines changed Expand file tree Collapse file tree 17 files changed +205
-1
lines changed Original file line number Diff line number Diff line change @@ -830,7 +830,19 @@ export async function generateModelString(
830
830
}
831
831
832
832
${ getFields }
833
- ${ setFields }
833
+ ${ setFields }
834
+
835
+ isDirty(column?: keyof ${ modelName } Type): boolean {
836
+ if (column) {
837
+ return this.attributes[column] !== this.originalAttributes[column]
838
+ }
839
+
840
+ return Object.entries(this.originalAttributes).some(([key, originalValue]) => {
841
+ const currentValue = (this.attributes as any)[key]
842
+
843
+ return currentValue !== originalValue
844
+ })
845
+ }
834
846
835
847
select(params: (keyof ${ modelName } Type)[] | RawBuilder<string> | string): ${ modelName } Model {
836
848
return ${ modelName } Model.select(params)
Original file line number Diff line number Diff line change @@ -140,6 +140,18 @@ export class AccessTokenModel {
140
140
this . attributes . updated_at = value
141
141
}
142
142
143
+ isDirty ( column ?: keyof AccessTokenType ) : boolean {
144
+ if ( column ) {
145
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
146
+ }
147
+
148
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
149
+ const currentValue = ( this . attributes as any ) [ key ]
150
+
151
+ return currentValue !== originalValue
152
+ } )
153
+ }
154
+
143
155
select ( params : ( keyof AccessTokenType ) [ ] | RawBuilder < string > | string ) : AccessTokenModel {
144
156
return AccessTokenModel . select ( params )
145
157
}
Original file line number Diff line number Diff line change @@ -176,6 +176,18 @@ export class DeploymentModel {
176
176
this . attributes . updated_at = value
177
177
}
178
178
179
+ isDirty ( column ?: keyof DeploymentType ) : boolean {
180
+ if ( column ) {
181
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
182
+ }
183
+
184
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
185
+ const currentValue = ( this . attributes as any ) [ key ]
186
+
187
+ return currentValue !== originalValue
188
+ } )
189
+ }
190
+
179
191
select ( params : ( keyof DeploymentType ) [ ] | RawBuilder < string > | string ) : DeploymentModel {
180
192
return DeploymentModel . select ( params )
181
193
}
Original file line number Diff line number Diff line change @@ -136,6 +136,18 @@ export class ErrorModel {
136
136
this . attributes . updated_at = value
137
137
}
138
138
139
+ isDirty ( column ?: keyof ErrorType ) : boolean {
140
+ if ( column ) {
141
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
142
+ }
143
+
144
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
145
+ const currentValue = ( this . attributes as any ) [ key ]
146
+
147
+ return currentValue !== originalValue
148
+ } )
149
+ }
150
+
139
151
select ( params : ( keyof ErrorType ) [ ] | RawBuilder < string > | string ) : ErrorModel {
140
152
return ErrorModel . select ( params )
141
153
}
Original file line number Diff line number Diff line change @@ -136,6 +136,18 @@ export class FailedJobModel {
136
136
this . attributes . updated_at = value
137
137
}
138
138
139
+ isDirty ( column ?: keyof FailedJobType ) : boolean {
140
+ if ( column ) {
141
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
142
+ }
143
+
144
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
145
+ const currentValue = ( this . attributes as any ) [ key ]
146
+
147
+ return currentValue !== originalValue
148
+ } )
149
+ }
150
+
139
151
select ( params : ( keyof FailedJobType ) [ ] | RawBuilder < string > | string ) : FailedJobModel {
140
152
return FailedJobModel . select ( params )
141
153
}
Original file line number Diff line number Diff line change @@ -136,6 +136,18 @@ export class JobModel {
136
136
this . attributes . updated_at = value
137
137
}
138
138
139
+ isDirty ( column ?: keyof JobType ) : boolean {
140
+ if ( column ) {
141
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
142
+ }
143
+
144
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
145
+ const currentValue = ( this . attributes as any ) [ key ]
146
+
147
+ return currentValue !== originalValue
148
+ } )
149
+ }
150
+
139
151
select ( params : ( keyof JobType ) [ ] | RawBuilder < string > | string ) : JobModel {
140
152
return JobModel . select ( params )
141
153
}
Original file line number Diff line number Diff line change @@ -185,6 +185,18 @@ export class PaymentMethodModel {
185
185
this . attributes . updated_at = value
186
186
}
187
187
188
+ isDirty ( column ?: keyof PaymentMethodType ) : boolean {
189
+ if ( column ) {
190
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
191
+ }
192
+
193
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
194
+ const currentValue = ( this . attributes as any ) [ key ]
195
+
196
+ return currentValue !== originalValue
197
+ } )
198
+ }
199
+
188
200
select ( params : ( keyof PaymentMethodType ) [ ] | RawBuilder < string > | string ) : PaymentMethodModel {
189
201
return PaymentMethodModel . select ( params )
190
202
}
Original file line number Diff line number Diff line change @@ -122,6 +122,18 @@ export class PostModel {
122
122
this . attributes . updated_at = value
123
123
}
124
124
125
+ isDirty ( column ?: keyof PostType ) : boolean {
126
+ if ( column ) {
127
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
128
+ }
129
+
130
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
131
+ const currentValue = ( this . attributes as any ) [ key ]
132
+
133
+ return currentValue !== originalValue
134
+ } )
135
+ }
136
+
125
137
select ( params : ( keyof PostType ) [ ] | RawBuilder < string > | string ) : PostModel {
126
138
return PostModel . select ( params )
127
139
}
Original file line number Diff line number Diff line change @@ -163,6 +163,18 @@ export class ProductModel {
163
163
this . attributes . updated_at = value
164
164
}
165
165
166
+ isDirty ( column ?: keyof ProductType ) : boolean {
167
+ if ( column ) {
168
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
169
+ }
170
+
171
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
172
+ const currentValue = ( this . attributes as any ) [ key ]
173
+
174
+ return currentValue !== originalValue
175
+ } )
176
+ }
177
+
166
178
select ( params : ( keyof ProductType ) [ ] | RawBuilder < string > | string ) : ProductModel {
167
179
return ProductModel . select ( params )
168
180
}
Original file line number Diff line number Diff line change @@ -127,6 +127,18 @@ export class ProjectModel {
127
127
this . attributes . updated_at = value
128
128
}
129
129
130
+ isDirty ( column ?: keyof ProjectType ) : boolean {
131
+ if ( column ) {
132
+ return this . attributes [ column ] !== this . originalAttributes [ column ]
133
+ }
134
+
135
+ return Object . entries ( this . originalAttributes ) . some ( ( [ key , originalValue ] ) => {
136
+ const currentValue = ( this . attributes as any ) [ key ]
137
+
138
+ return currentValue !== originalValue
139
+ } )
140
+ }
141
+
130
142
select ( params : ( keyof ProjectType ) [ ] | RawBuilder < string > | string ) : ProjectModel {
131
143
return ProjectModel . select ( params )
132
144
}
You can’t perform that action at this time.
0 commit comments