IModelDb Class

An iModel database file. The database file is either a local copy (briefcase) of an iModel managed by iModelHub or a read-only snapshot used for archival and data transfer purposes.

IModelDb raises a set of events to allow apps and subsystems to track IModelDb object life cycle, including IModelDb.onOpen and IModelDb.onOpened.

see learning about IModelDb




Name Description
abandonChanges(): void Abandon pending changes in this iModel  
cancelSnap(sessionId: string): void Cancel a previously requested snap.  
clearSqliteStatementCache(): void Empty the SqliteStatementCache for this iModel.  
clearStatementCache(): void Empty the ECSqlStatementCache for this iModel.  
close(requestContext: AuthorizedClientRequestContext, keepBriefcase: KeepBriefcase = KeepBriefcase.Yes): Promise<void> Close this iModel, if it is currently open.  
closeSnapshot(): void Close this local read-only iModel snapshot, if it is currently open. Beta
constructEntity<T extends Entity>(props: EntityProps): T extends Entity Construct an entity (Element or Model) from an iModel.  
containsClass(classFullName: string): boolean Query if this iModel contains the definition of the specified class.  
createSnapshot(snapshotFile: string): IModelDb Create a local iModel snapshot file using this iModel as a seed or starting point. Beta
deleteFileProperty(prop: FilePropertyProps): DbResult delete a "file property" from this iModel  
embedFont(prop: FontProps): FontProps    
executeQuery(ecsql: string, bindings?: any[] | object): any[] Execute a query against this IModelDb. Deprecated
exportGraphics(exportProps: ExportGraphicsProps): DbResult Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb. Beta
getBriefcaseId(): BriefcaseId Get the briefcase Id of this iModel  
getGeoCoordinatesFromIModelCoordinates(requestContext: ClientRequestContext, props: string): Promise<GeoCoordinatesResponseProps> Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input  
getGuid(): GuidString Get the GUID of this iModel.  
getIModelCoordinatesFromGeoCoordinates(requestContext: ClientRequestContext, props: string): Promise<IModelCoordinatesResponseProps> Get the IModel coordinate corresponding to each GeoCoordinate point in the input  
getJsClass<T extends Entity>(classFullName: string): T extends Entity Get the JavaScript class that handles a given entity class.  
Get metadata for a class.  
importSchema(requestContext: ClientRequestContext | AuthorizedClientRequestContext, schemaFileName: string): Promise<void> Import an ECSchema.  
prepareStatement(sql: string): ECSqlStatement Prepare an ECSQL statement.  
pullAndMergeChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise<void> Pull and Merge changes from iModelHub Beta
pushChanges(requestContext: AuthorizedClientRequestContext, describer?: ChangeSetDescriber): Promise<void> Push changes to iModelHub Beta
query(ecsql: string, bindings?: any[] | object, limitRows?: number, quota?: QueryQuota, priority?: QueryPriority): AsyncIterableIterator<any> Execute a query and stream its results
The result of the query is async iterator over the rows.
queryEntityIds(params: EntityQueryParams): Id64Set Query for a set of entity ids, given an EntityQueryParams  
queryFilePropertyBlob(prop: FilePropertyProps): Uint8Array | undefined Query a "file property" from this iModel, as a blob.  
queryFilePropertyString(prop: FilePropertyProps): string | undefined Query a "file property" from this iModel, as a string.  
queryNextAvailableFileProperty(prop: FilePropertyProps): number Query for the next available major id for a "file property" from this iModel.  
queryRowCount(ecsql: string, bindings?: any[] | object): Promise<number> Compute number of rows that would be returned by the ECSQL.  
readFontJson(): string    
reinstateChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise<void> Reinstate a previously reversed set of changes Beta
requestSnap(requestContext: ClientRequestContext, sessionId: string, props: SnapRequestProps): Promise<SnapResponseProps>    
reverseChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise<void> Reverse a previously merged set of changes Beta
saveChanges(description?: string): void Commit pending changes to this iModel.  
saveFileProperty(prop: FilePropertyProps, strValue: string | undefined, blobVal?: Uint8Array): DbResult Save a "file property" to this iModel  
setAsMaster(guid?: GuidString): void Set iModel as Master copy.  
setGuid(guid: GuidString): DbResult Set the GUID of this iModel.  
updateEcefLocation(ecef: EcefLocation): void Update the EcefLocation of this iModel.  
updateIModelProps(): void Update the IModelProps of this iModel in the database.  
updateProjectExtents(newExtents: AxisAlignedBox3d): void Update the project extents for this iModel.  
withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T): T Use a prepared ECSQL statement.  
create(requestContext: AuthorizedClientRequestContext, contextId: string, iModelName: string, args: CreateIModelProps): Promise<IModelDb> Static Create an iModel on iModelHub  
createSnapshot(snapshotFile: string, args: CreateIModelProps): IModelDb Static Create an empty local iModel snapshot file. Beta
find(iModelToken: IModelToken): IModelDb Static Find an already open IModelDb.  
Invoke a callback on each property of the specified class, optionally including superclass properties.  
open(requestContext: AuthorizedClientRequestContext, contextId: string, iModelId: string, openParams: OpenParams = OpenParams.pullAndPush(), version: IModelVersion = IModelVersion.latest()): Promise<IModelDb> Static Open an iModel from iModelHub.  
openSnapshot(filePath: string): IModelDb Static Open a local iModel snapshot. Beta

Inherited methods

Name Inherited from Description
cartographicToSpatialFromEcef(cartographic: Cartographic, result?: Point3d): Point3d IModel Convert a ($Cartographic$refLinkSource=imodeljs-backend/D:/vsts_b/5/s/core/backend/node_modules/@bentley/imodeljs-common/lib/IModel.d.ts@193) to a point in this iModel's Spatial coordinates using its ecefLocation.
ecefToSpatial(ecef: XYAndZ, result?: Point3d): Point3d IModel Convert a point in ECEF coordinates to a point in this iModel's Spatial coordinates using its ecefLocation.
getEcefTransform(): Transform IModel Get the Transform from this iModel's Spatial coordinates to ECEF coordinates using its ecefLocation.
setEcefLocation(ecef: EcefLocationProps): void IModel Set the EcefLocation for this iModel.
spatialToCartographicFromEcef(spatial: XYAndZ, result?: Cartographic): Cartographic IModel Convert a point in this iModel's Spatial coordinates to a ($Cartographic$refLinkSource=imodeljs-backend/D:/vsts_b/5/s/core/backend/node_modules/@bentley/imodeljs-common/lib/IModel.d.ts@184) using its ecefLocation.
spatialToEcef(spatial: XYAndZ, result?: Point3d): Point3d IModel Convert a point in this iModel's Spatial coordinates to an ECEF point using its ecefLocation.
getDefaultSubCategoryId(categoryId: Id64String): Id64String Static IModel Get the default subCategoryId for the supplied categoryId


Name Type Description
_fontMap Protected undefined | FontMap    
codeSpecs Accessor ReadOnly CodeSpecs Get the CodeSpecs in this IModel.  
concurrencyControl Accessor ReadOnly ConcurrencyControl Get the ConcurrencyControl for this IModel. Beta
defaultLimit Static 1000    
elements IModelDb.Elements    
fontMap Accessor ReadOnly FontMap    
isReadonly Accessor ReadOnly boolean Check if this iModel has been opened read-only or not.  
isStandalone Accessor ReadOnly boolean Returns true if this is a standalone iModel Deprecated
maxLimit Static 10000    
models IModelDb.Models    
onBeforeClose BeEvent<() => void> Event called when the iModel is about to be closed  
onChangesetApplied BeEvent<() => void> Event called after a changeset is applied to this IModelDb.  
onCreate Static BeEvent<(_requestContext: AuthorizedClientRequestContext, _contextId: string, _args: CreateIModelProps) => void> Event raised just before an IModelDb is created in iModelHub.  
onCreated Static BeEvent<(_imodelDb: IModelDb) => void> Event raised just after an IModelDb is created in iModelHub.  
onOpen Static BeEvent<(_requestContext: AuthorizedClientRequestContext, _contextId: string, _iModelId: string, _openParams: OpenParams, _version: IModelVersion) => void> Event raised just before an IModelDb is opened.  
onOpened Static BeEvent<(_requestContext: AuthorizedClientRequestContext, _imodelDb: IModelDb) => void> Event raised just after an IModelDb is opened.  
openParams OpenParams Get the parameters used to open this iModel  
relationships Accessor ReadOnly Relationships Get the linkTableRelationships for this IModel  
tiles IModelDb.Tiles    
txns TxnManager   Beta
views IModelDb.Views    

Inherited properties

Name Type Inherited from Description
dictionaryId Static Id64String IModel The Id of the dictionary model.
ecefLocation EcefLocation | undefined IModel The EcefLocation of the iModel in Earth Centered Earth Fixed coordinates.
globalOrigin Point3d IModel An offset to be applied to all spatial coordinates.
iModelToken IModelToken IModel The token that can be used to find this iModel instance.
isGeoLocated boolean IModel True if this iModel has an EcefLocation.
name string IModel Name of the iModel
projectExtents AxisAlignedBox3d IModel The volume, in spatial coordinates, inside which the entire project is contained.
repositoryModelId Static Id64String IModel The Id of the repository model.
rootSubject RootSubjectProps IModel The name and description of the root subject of this iModel
rootSubjectId Static Id64String IModel The Id of the root subject element.

Defined in

Last Updated: 03 June, 2019