tryGetModel Method

Get the Model with the specified identifier.

tryGetModel<T extends Model>(modelId: Id64String, modelClass?: EntityClassType<Model>): T extends Model | undefined

throws IModelError if the model cannot be loaded.

note Useful for cases when a model may or may not exist and throwing an Error would be overkill.

see IModelDb.Models.getModel

Parameter Type Description
modelId Id64String The Model identifier.
modelClass EntityClassType<Model> Optional class to validate instance against. This parameter can accept abstract or concrete classes, but should be the same as the template (T) parameter.

Returns - The Model or undefined if the model is not found or fails validation when modelClass is specified.

Defined in

Last Updated: 18 November, 2020