From 32195bc619f0299f5ea8a845940d0d84873cceef Mon Sep 17 00:00:00 2001 From: tim-s-ccs Date: Thu, 24 Feb 2022 09:06:42 +0000 Subject: [PATCH] Get the request from the model --- src/models/activeModel.ts | 8 ++++---- src/types/models/model.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/activeModel.ts b/src/models/activeModel.ts index 31950fe..e7a2f1a 100644 --- a/src/models/activeModel.ts +++ b/src/models/activeModel.ts @@ -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) { @@ -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 @@ -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) diff --git a/src/types/models/model.ts b/src/types/models/model.ts index ee9c7aa..de1014e 100644 --- a/src/types/models/model.ts +++ b/src/types/models/model.ts @@ -18,7 +18,7 @@ export interface ActiveModelInterface { addError(attribute: string, error: string, message: string): void errorList(): Array attributes(): TableRow - assignAttributes(req: Request, data?: ActiveModelData): void + assignAttributes(data?: ActiveModelData): void save(call: string): boolean create(): boolean }