Skip to content

web-backend


Class: NestedModelHelperService

Defined in: packages/web-backend/src/nestedModels/nested-model-helper.service.ts:34

Helper service to link nested models to typed models and perform common updates. Used by feature-specific nested model services.

Constructors

Constructor

new NestedModelHelperService(internalEventsModel, internalHazardsModel, externalHazardsModel, fullScopeModel): NestedModelHelperService

Defined in: packages/web-backend/src/nestedModels/nested-model-helper.service.ts:43

Construct the helper with injected typed model collections.

Parameters

internalEventsModel

Model<InternalEventsDocument>

Mongoose model for Internal Events typed models

internalHazardsModel

Model<InternalHazardsDocument>

Mongoose model for Internal Hazards typed models

externalHazardsModel

Model<ExternalHazardsDocument>

Mongoose model for External Hazards typed models

fullScopeModel

Model<FullScopeDocument>

Mongoose model for Full Scope typed models

Returns

NestedModelHelperService

Methods

AddNestedModelToTypedModel()

AddNestedModelToTypedModel(typedModel, nestedModel, typedModelId, nestedModelId): Promise<void>

Defined in: packages/web-backend/src/nestedModels/nested-model-helper.service.ts:62

Link a nested model document into a typed model document by pushing its id into the appropriate array field.

Parameters

typedModel

TypedModelType

Target typed model collection name

nestedModel

NestedModelType

Nested model property key to update on the typed model

typedModelId

string

ID of the typed model document

nestedModelId

string

ID of the nested model to link

Returns

Promise<void>


RemoveNestedModelToTypedModel()

RemoveNestedModelToTypedModel(typedModel, nestedModel, typedModelId, nestedModelId): Promise<void>

Defined in: packages/web-backend/src/nestedModels/nested-model-helper.service.ts:108

Unlink a nested model document from a typed model document by pulling its id from the appropriate array field.

Parameters

typedModel

TypedModelType

Target typed model collection name

nestedModel

NestedModelType

Nested model property key to update on the typed model

typedModelId

string

ID of the typed model document

nestedModelId

string

ID of the nested model to unlink

Returns

Promise<void>