Class: TypedModelService
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:21
Service for typed model lifecycle and persistence. Handles counters and CRUD for model variants (Internal/External Hazards, Full Scope, Internal Events).
Constructors
Constructor
new TypedModelService(
modelCounterModel,internalEventsModel,internalHazardsModel,externalHazardsModel,fullScopeModel):TypedModelService
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:31
Construct the service with injected models for typed model variants and counters.
Parameters
modelCounterModel
Model<ModelCounterDocument>
Counter collection used to allocate incremental IDs for typed models
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
TypedModelService
Methods
addNestedToExternalHazard()
addNestedToExternalHazard(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:473
adds a nested model to a larger model
Parameters
modelId
number
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
addNestedToFullScope()
addNestedToFullScope(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:497
adds a nested model to a larger model
Parameters
modelId
number
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
addNestedToInternalEvent()
addNestedToInternalEvent(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:425
adds a nested model to a larger model
Parameters
modelId
number
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
addNestedToInternalHazard()
addNestedToInternalHazard(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:449
adds a nested model to a larger model
Parameters
modelId
number
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
createExternalHazardModel()
createExternalHazardModel(
body):Promise<TypedModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:90
method for creating a new internal evnet model in the database
Parameters
body
Partial<ExternalHazards>
takes in the model type that is requested in the name
Returns
Promise<TypedModel>
promise with the model type
createFullScopeModel()
createFullScopeModel(
body):Promise<TypedModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:101
method for creating a new internal event model in the database
Parameters
body
Partial<FullScope>
takes in the model type that is requested in the name
Returns
Promise<TypedModel>
promise with the model type
createInternalEventModel()
createInternalEventModel(
body):Promise<TypedModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:68
method for creating a new internal evnet model in the database
Parameters
body
Partial<InternalEvents>
takes in the model type that is requested in the name
Returns
Promise<TypedModel>
promise with the model type
createInternalHazardModel()
createInternalHazardModel(
body):Promise<TypedModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:79
method for creating a new internal evnet model in the database
Parameters
body
Partial<InternalHazards>
takes in the model type that is requested in the name
Returns
Promise<TypedModel>
promise with the model type
deleteExternalHazard()
deleteExternalHazard(
modelId,userId):Promise<ExternalHazardsModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:369
deletes an external hazard with the given id from a user, and from the database if these is only 1 user
Parameters
modelId
number
the id of the external hazard to be deleted
userId
number
the id of the user for whom model is to be deleted
Returns
Promise<ExternalHazardsModel>
the deleted model
deleteFullScope()
deleteFullScope(
modelId,userId):Promise<FullScopeModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:397
deletes a full scope with the given id from a user, and from the database if these is only 1 user
Parameters
modelId
number
the id of the full scope to be deleted
userId
number
the user for whom the model is supposed to be deleted
Returns
Promise<FullScopeModel>
the deleted model
deleteInternalEvent()
deleteInternalEvent(
modelId,userId):Promise<InternalEventsModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:310
deletes an internal event with the given id from a user, and from the database if these is only 1 user
Parameters
modelId
number
the id of the internal event to be deleted
userId
number
the user for which model is to be deleted
Returns
Promise<InternalEventsModel>
the deleted model
deleteInternalHazard()
deleteInternalHazard(
modelId,userId):Promise<InternalHazardsModel>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:339
deletes an internal hazard with the given id from a user, and from the database if these is only 1 user
Parameters
modelId
number
the id of the internal hazard to be deleted
userId
number
the user for whom the model is to be deleted
Returns
Promise<InternalHazardsModel>
the deleted model
deleteNestedFromExternalHazard()
deleteNestedFromExternalHazard(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:575
deletes a nested model to a larger model
Parameters
modelId
string
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
deleteNestedFromFullScope()
deleteNestedFromFullScope(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:599
deletes a nested model to a larger model
Parameters
modelId
string
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
deleteNestedFromInternalEvent()
deleteNestedFromInternalEvent(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:523
deletes a nested model to a larger model
Parameters
modelId
string
id of the typed model
nestedId
id of the nested model
string | number
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
deleteNestedFromInternalHazard()
deleteNestedFromInternalHazard(
modelId,nestedId,nestedType):Promise<TypedModelJSON>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:551
deletes a nested model to a larger model
Parameters
modelId
string
id of the typed model
nestedId
number
id of the nested model
nestedType
string
string in camelCase of the nested model type
Returns
Promise<TypedModelJSON>
a promise with the new typed model
getExternalHazard()
getExternalHazard(
modelId,userId):Promise<ExternalHazards>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:288
function to return all of the desired model type of a given user
Parameters
modelId
string
the model id to fetch
userId
number
the user who's models are to be loaded
Returns
Promise<ExternalHazards>
the list of models for the type that the user has been assigned to
getExternalHazards()
getExternalHazards(
userId):Promise<ExternalHazards[]>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:244
function to return all of the desired model type of a given user
Parameters
userId
number
the user who's models are to be loaded
Returns
Promise<ExternalHazards[]>
the list of models for the type that the user has been assigned to
getFullScope()
getFullScope(
modelId,userId):Promise<FullScope>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:298
function to return all of the desired model type of a given user
Parameters
modelId
string
the model id to fetch
userId
number
the user who's models are to be loaded
Returns
Promise<FullScope>
the list of models for the type that the user has been assigned to
getFullScopes()
getFullScopes(
userId):Promise<FullScope[]>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:253
function to return all of the desired model type of a given user
Parameters
userId
number
the user who's models are to be loaded
Returns
Promise<FullScope[]>
the list of models for the type that the user has been assigned to
getInternalEvent()
getInternalEvent(
modelId,userId):Promise<InternalEvents>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:266
note for all: the id thing is to exclude the _id mongoose stuff from being in the output function to return all of the desired model type of a given user
Parameters
modelId
string
the model id to fetch
userId
number
the user who's models are to be loaded
Returns
Promise<InternalEvents>
the list of models for the type that the user has been assigned to
getInternalEvents()
getInternalEvents(
userId):Promise<InternalEvents[]>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:224
function to return all of the desired model type of a given user
Parameters
userId
number
the user who's models are to be loaded
Returns
Promise<InternalEvents[]>
the list of models for the type that the user has been assigned to
getInternalHazard()
getInternalHazard(
modelId,userId):Promise<InternalHazards>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:278
function to return all of the desired model type of a given user
Parameters
modelId
string
the model id to fetch
userId
number
the user who's models are to be loaded
Returns
Promise<InternalHazards>
the list of models for the type that the user has been assigned to
getInternalHazards()
getInternalHazards(
userId):Promise<InternalHazards[]>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:235
function to return all of the desired model type of a given user
Parameters
userId
number
the user who's models are to be loaded
Returns
Promise<InternalHazards[]>
the list of models for the type that the user has been assigned to
getNextModelValue()
getNextModelValue(
name):Promise<number>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:51
this was copied from elsewhere, its to create a counter, it should probably have the suer counter named something else now but oh well
Parameters
name
string
Name of the counter
Returns
Promise<number>
ID number
Remarks
Generates an ID for the newly created user in an incremental order of 1. Initially if no user exists, the serial ID starts from 1.
patchExternalHazard()
patchExternalHazard(
modelId,userId,model):Promise<ExternalHazards>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:170
updates a single model at the given id, replacing it with a new one
Parameters
modelId
string
the id of the model to be updated
userId
number
the user who must be on the model
model
Partial<ExternalHazards>
the new model we want to put at the id
Returns
Promise<ExternalHazards>
the new ExternalHazardsModel
patchFullScope()
patchFullScope(
modelId,userId,model):Promise<FullScope>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:199
updates a single model at the given id, replacing it with a new one
Parameters
modelId
string
the id of the model to be updated
userId
number
the user who must be on the model
model
Partial<FullScope>
the new model we want to put at the id
Returns
Promise<FullScope>
the new FulLScopeModel
patchInternalEvent()
patchInternalEvent(
modelId,userId,model):Promise<InternalEvents>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:116
updates a single model at the given id, replacing it with a new one
Parameters
modelId
string
the id of the model to be updated
userId
number
the user who must be on the model
model
Partial<InternalEvents>
the new model we want to put at the id
Returns
Promise<InternalEvents>
the new InternalEventsModel
patchInternalHazard()
patchInternalHazard(
modelId,userId,model):Promise<InternalHazards>
Defined in: packages/web-backend/src/typedModel/typedModel.service.ts:141
updates a single model at the given id, replacing it with a new one
Parameters
modelId
string
the id of the model to be updated
userId
number
the user who must be on the model
model
Partial<InternalHazards>
the new model we want to put at the id
Returns
Promise<InternalHazards>
the new InternalHazardsModel
