tryGetModel Method
Get the Model with the specified identifier.
tryGetModel<T extends Model>(modelId: string, modelClass?: EntityClassType<Model>): undefined | T
@returns  The Model or undefined if the model is not found or fails validation when modelClass is specified.
@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 getModel
| Parameter | Type | Description | 
|---|---|---|
| modelId | string | 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 - undefined | T
The Model or undefined if the model is not found or fails validation when modelClass is specified.
Defined in
- core/backend/src/IModelDb.ts Line 1933
Last Updated: 24 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.