SchemaLoader Class
A utility class for loading EC Schema objects using a function that returns schema json for a given schema name. Loaded schemas are held in memory within a schema context managed by SchemaLoader. The SchemaLoader object should be held in memory if multiple calls to SchemaLoader.getSchema or SchemaLoader.tryGetSchema is a possibility, thereby avoiding unnecessary schema retrievals from the function.
** Example **
// To use the schemas already in an iModel create a SchemaLoader that pulls schemas from the iModel
// The SchemaLoader can load schemas from another location or you can create an empty context using the
// SchemaContext constructor
const loader = new SchemaLoader((name) => iModelDb.getSchemaProps(name));
const editor = new SchemaContextEditor(loader.context);
Methods
Name | Description | |
---|---|---|
constructor(getSchema: SchemaPropsGetter): SchemaLoader | ||
getSchema<T extends Schema<T>>(schemaName: string): T | Get a schema by name | |
tryGetSchema<T extends Schema<T>>(schemaName: string): undefined | T | Attempts to get a schema by name |
Properties
Name | Type | Description | |
---|---|---|---|
context Accessor ReadOnly | SchemaContext | Gets the SchemaContext used by the loader. |
Defined in
Last Updated: 04 December, 2023