Skip to content

Commit ea23c98

Browse files
chore: wip
1 parent 227e3cd commit ea23c98

File tree

17 files changed

+205
-1
lines changed

17 files changed

+205
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,19 @@ export async function generateModelString(
830830
}
831831
832832
${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+
}
834846
835847
select(params: (keyof ${modelName}Type)[] | RawBuilder<string> | string): ${modelName}Model {
836848
return ${modelName}Model.select(params)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ export class AccessTokenModel {
140140
this.attributes.updated_at = value
141141
}
142142

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+
143155
select(params: (keyof AccessTokenType)[] | RawBuilder<string> | string): AccessTokenModel {
144156
return AccessTokenModel.select(params)
145157
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ export class DeploymentModel {
176176
this.attributes.updated_at = value
177177
}
178178

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+
179191
select(params: (keyof DeploymentType)[] | RawBuilder<string> | string): DeploymentModel {
180192
return DeploymentModel.select(params)
181193
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ export class ErrorModel {
136136
this.attributes.updated_at = value
137137
}
138138

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+
139151
select(params: (keyof ErrorType)[] | RawBuilder<string> | string): ErrorModel {
140152
return ErrorModel.select(params)
141153
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ export class FailedJobModel {
136136
this.attributes.updated_at = value
137137
}
138138

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+
139151
select(params: (keyof FailedJobType)[] | RawBuilder<string> | string): FailedJobModel {
140152
return FailedJobModel.select(params)
141153
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ export class JobModel {
136136
this.attributes.updated_at = value
137137
}
138138

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+
139151
select(params: (keyof JobType)[] | RawBuilder<string> | string): JobModel {
140152
return JobModel.select(params)
141153
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ export class PaymentMethodModel {
185185
this.attributes.updated_at = value
186186
}
187187

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+
188200
select(params: (keyof PaymentMethodType)[] | RawBuilder<string> | string): PaymentMethodModel {
189201
return PaymentMethodModel.select(params)
190202
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ export class PostModel {
122122
this.attributes.updated_at = value
123123
}
124124

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+
125137
select(params: (keyof PostType)[] | RawBuilder<string> | string): PostModel {
126138
return PostModel.select(params)
127139
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ export class ProductModel {
163163
this.attributes.updated_at = value
164164
}
165165

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+
166178
select(params: (keyof ProductType)[] | RawBuilder<string> | string): ProductModel {
167179
return ProductModel.select(params)
168180
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ export class ProjectModel {
127127
this.attributes.updated_at = value
128128
}
129129

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+
130142
select(params: (keyof ProjectType)[] | RawBuilder<string> | string): ProjectModel {
131143
return ProjectModel.select(params)
132144
}

0 commit comments

Comments
 (0)