Skip to content

Commit

Permalink
Get the request from the model
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-s-ccs committed Feb 24, 2022
1 parent 650e1c9 commit 32195bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/models/activeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ abstract class ActiveModel extends Model implements ActiveModelInterface {
})) as TableRow
}

assignAttributes = (req: Request, data?: ActiveModelData): void => {
assignAttributes = (data?: ActiveModelData): void => {
if (data === undefined) return

for (const attribute in this.modelSchema) {
Expand All @@ -206,7 +206,7 @@ abstract class ActiveModel extends Model implements ActiveModelInterface {
}, {})

this.data[attribute].forEach((activeModel: ActiveModel) => {
activeModel.assignAttributes(req, activeModels[activeModel.data.id])
activeModel.assignAttributes(activeModels[activeModel.data.id])
})
} else if (arrayItemConstuctor.prototype instanceof StaticModel) {
// TODO: Chnage to somthing that is not any
Expand All @@ -221,9 +221,9 @@ abstract class ActiveModel extends Model implements ActiveModelInterface {
}
} else if (attributeConstructor.constructor.prototype instanceof ActiveModel) {
if (this.data[attribute] === undefined) {
this.data[attribute] = (attributeConstructor.constructor as any).build(req, data[attribute])
this.data[attribute] = (attributeConstructor.constructor as any).build(this.req, data[attribute])
} else {
(this.data[attribute] as ActiveModel).assignAttributes(req, data[attribute])
(this.data[attribute] as ActiveModel).assignAttributes(data[attribute])
}
} else if (attributeConstructor.constructor.prototype instanceof StaticModel) {
const primaryKeyValue = utils.cast(data[attribute], String)
Expand Down
2 changes: 1 addition & 1 deletion src/types/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface ActiveModelInterface {
addError(attribute: string, error: string, message: string): void
errorList(): Array<ListError>
attributes(): TableRow
assignAttributes(req: Request, data?: ActiveModelData): void
assignAttributes(data?: ActiveModelData): void
save(call: string): boolean
create(): boolean
}
Expand Down

0 comments on commit 32195bc

Please sign in to comment.