StandaloneDb Class

Standalone iModels are read/write files that are not associated with an iTwin or managed by iModelHub. They are relevant only for testing, or for small-scale single-user scenarios. Standalone iModels are designed such that the API for Standalone iModels and Briefcase iModels (those synchronized with iModelHub) are as similar and consistent as possible. This leads to a straightforward process where the a user starts with StandaloneDb and can optionally choose to upgrade to an iTwin.

Some additional details. Standalone iModels:

  • always have Guid.empty for their iTwinId (they are "unassociated" files)
  • always have BriefcaseId === BriefcaseIdValue.Unassigned
  • are connected to the frontend via BriefcaseConnection.openStandalone
  • may be opened without supplying any user credentials
  • may be opened read/write
  • cannot apply a changeset to nor generate a changesets (since there is no timeline from which to get/push changesets)

Extends

Methods

Name Description
constructor(args: { briefcaseId: number, key: string, nativeDb: DgnDb, openMode: OpenMode }): StandaloneDb Protected    
createEmpty(filePath: string, args: CreateEmptyStandaloneIModelProps): StandaloneDb Static Create an empty standalone iModel.  
findByKey(key: string): StandaloneDb Static Find an open IModelDb by its key.  
openFile(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, options?: SnapshotDbOpenArgs): StandaloneDb Static Open a standalone iModel file.  
tryFindByKey(key: string): undefined | StandaloneDb Static Attempt to find an open IModelDb by key.  
upgradeStandaloneSchemas(filePath: string): void Static Upgrades the schemas in the standalone iModel file.  

Inherited methods

Name Inherited from Description
abandonChanges(): void BriefcaseDb Abandon pending changes in this iModel.
acquireSchemaLock(): Promise<void> BriefcaseDb Acquire the exclusive schema lock on this iModel.
addNewFont(name: string, type?: FontType): number BriefcaseDb Add a new font name/type to the FontMap for this iModel and return its FontId.
cartographicToSpatialFromEcef(cartographic: Cartographic, result?: Point3d): Point3d BriefcaseDb Convert a Cartographic to a point in this iModel's Spatial coordinates using its ecefLocation.
clearCaches(): void BriefcaseDb Clear all in-memory caches held in this IModelDb.
close(): void BriefcaseDb Close this IModel, if it is currently open.
computeProjectExtents(options?: ComputeProjectExtentsOptions): ComputedProjectExtents BriefcaseDb Compute an appropriate project extents for this iModel based on the ranges of all spatial elements.
constructEntity<T extends Entity<T>>(props: EntityProps): T BriefcaseDb Construct an entity (Element or Model) from an iModel.
containsClass(classFullName: string): boolean BriefcaseDb Query if this iModel contains the definition of the specified class.
createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader BriefcaseDb Allow to execute query and read results along with meta data.
deleteFileProperty(prop: FilePropertyProps): void BriefcaseDb delete a "file property" from this iModel
deleteSettingDictionary(name: string): void BriefcaseDb Delete a SettingDictionary, previously added with BriefcaseDb.saveSettingDictionary, from this iModel.
ecefToSpatial(ecef: Readonly<WritableXYAndZ>, result?: Point3d): Point3d BriefcaseDb Convert a point in ECEF coordinates to a point in this iModel's Spatial coordinates using its BriefcaseDb.ecefLocation.
exportGraphics(exportProps: ExportGraphicsOptions): DbResult BriefcaseDb Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
exportPartGraphics(exportProps: ExportPartGraphicsOptions): DbResult BriefcaseDb Exports meshes suitable for graphics APIs from a specified GeometryPart
generateElementGraphics(request: ElementGraphicsRequestProps): Promise<undefined | Uint8Array> BriefcaseDb Generate graphics for an element or geometry stream.
getBriefcaseId(): number BriefcaseDb Get the briefcase Id of this iModel
getEcefTransform(): Transform BriefcaseDb Get the Transform from this iModel's Spatial coordinates to ECEF coordinates using its ecefLocation.
getGeoCoordinatesFromIModelCoordinates(props: GeoCoordinatesRequestProps): Promise<GeoCoordinatesResponseProps> BriefcaseDb Get the GeoCoordinate (longitude, latitude, elevation) corresponding to each IModel Coordinate point in the input
getGeometryContainment(props: GeometryContainmentRequestProps): Promise<GeometryContainmentResponseProps> BriefcaseDb Get the clip containment status for the supplied elements.
getIModelCoordinatesFromGeoCoordinates(props: IModelCoordinatesRequestProps): Promise<IModelCoordinatesResponseProps> BriefcaseDb Get the IModel coordinate corresponding to each GeoCoordinate point in the input
getJsClass<T extends undefined>(classFullName: string): T BriefcaseDb Get the JavaScript class that handles a given entity class.
getMassProperties(props: MassPropertiesRequestProps): Promise<MassPropertiesResponseProps> BriefcaseDb Get the mass properties for the supplied elements.
BriefcaseDb Get metadata for a class.
getRpcProps(): IModelRpcProps BriefcaseDb Return a token for RPC operations.
getSchemaProps(name: string): ECSchemaProps BriefcaseDb Returns the full schema for the input name.
importSchemas(schemaFileNames: string[], options?: SchemaImportOptions): Promise<void> BriefcaseDb Import an ECSchema.
isBriefcaseDb(): this is BriefcaseDb BriefcaseDb Type guard for instanceof BriefcaseDb
isSnapshotDb(): this is SnapshotDb BriefcaseDb Type guard for instanceof SnapshotDb
performCheckpoint(): void BriefcaseDb Save all changes and perform a checkpoint on this IModelDb.
prepareStatement(sql: string, logErrors: boolean = true): ECSqlStatement BriefcaseDb Prepare an ECSQL statement.
pullChanges(arg?: PullChangesArgs): Promise<void> BriefcaseDb Pull and apply changesets from iModelHub
pushChanges(arg: PushChangesArgs): Promise<void> BriefcaseDb Push changes to iModelHub.
query(ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> BriefcaseDb Execute a query and stream its results
queryEntityIds(params: EntityQueryParams): Id64Set BriefcaseDb Query for a set of entity ids, given an EntityQueryParams
queryFilePropertyBlob(prop: FilePropertyProps): undefined | Uint8Array BriefcaseDb Query a "file property" from this iModel, as a blob.
queryFilePropertyString(prop: FilePropertyProps): undefined | string BriefcaseDb Query a "file property" from this iModel, as a string.
queryNextAvailableFileProperty(prop: FilePropertyProps): number BriefcaseDb Query for the next available major id for a "file property" from this iModel.
queryRowCount(ecsql: string, params?: QueryBinder): Promise<number> BriefcaseDb Compute number of rows that would be returned by the ECSQL.
querySchemaVersion(schemaName: string): undefined | string BriefcaseDb Query for a schema of the specified name in this iModel.
restartQuery(token: string, ecsql: string, params?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<any> BriefcaseDb Cancel any previous query with same token and run execute the current specified query.
saveChanges(description?: string): void BriefcaseDb Commit pending changes to this iModel.
saveFileProperty(prop: FilePropertyProps, strValue: undefined | string, blobVal?: Uint8Array): void BriefcaseDb Save a "file property" to this iModel
saveSettingDictionary(name: string, dict: SettingObject): void BriefcaseDb Save a SettingDictionary in this iModel that will be loaded into workspace.settings every time this iModel is opened in future sessions.
setEcefLocation(ecef: EcefLocationProps): void BriefcaseDb Set the EcefLocation for this iModel.
setGeographicCoordinateSystem(geoCRS: GeographicCRSProps): void BriefcaseDb Sets the geographic coordinate reference system from GeographicCRSProps.
spatialToCartographicFromEcef(spatial: Readonly<WritableXYAndZ>, result?: Cartographic): Cartographic BriefcaseDb Convert a point in this iModel's Spatial coordinates to a Cartographic using its ecefLocation.
spatialToEcef(spatial: Readonly<WritableXYAndZ>, result?: Point3d): Point3d BriefcaseDb Convert a point in this iModel's Spatial coordinates to an ECEF point using its ecefLocation.
tryPrepareStatement(sql: string): undefined | ECSqlStatement BriefcaseDb Prepare an ECSQL statement.
updateEcefLocation(ecef: EcefLocation): void BriefcaseDb Update the EcefLocation of this iModel.
updateIModelProps(): void BriefcaseDb Update the IModelProps of this iModel in the database.
updateProjectExtents(newExtents: Range3d): void BriefcaseDb Update the project extents for this iModel.
withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors: boolean = true): T BriefcaseDb Use a prepared SQL statement, potentially from the statement cache.
withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors: boolean = true): T BriefcaseDb Use a prepared ECSQL statement, potentially from the statement cache.
withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors: boolean = true): T BriefcaseDb Prepared and execute a callback on a SQL statement.
withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors: boolean = true): T BriefcaseDb Prepared and execute a callback on an ECSQL statement.
findByFilename(fileName: string): undefined | IModelDb Static BriefcaseDb Find an opened instance of any subclass of IModelDb, by filename
BriefcaseDb Invoke a callback on each property of the specified class, optionally including superclass properties.
getDefaultSubCategoryId(categoryId: string): string Static BriefcaseDb Get the default subCategoryId for the supplied categoryId
open(args: OpenBriefcaseArgs): Promise<BriefcaseDb> Static BriefcaseDb Open a briefcase file and return a new BriefcaseDb to interact with it.
upgradeSchemas(briefcase: OpenBriefcaseArgs): Promise<void> Static BriefcaseDb Upgrades the schemas in the iModel based on the current version of the software.
validateSchemas(filePath: string, forReadWrite: boolean): SchemaState Static BriefcaseDb Determines if the schemas in the Db must or can be upgraded by comparing them with those included in the

Properties

Name Type Description
isStandalone Accessor ReadOnly boolean    
useLockServer Accessor ProtectedReadOnly boolean    

Inherited properties

Name Type Inherited from Description
_fontMap Protected undefined | FontMap BriefcaseDb  
_openMode Protected OpenMode BriefcaseDb  
briefcaseId Readonly number BriefcaseDb  
changeset ChangesetIdWithIndex BriefcaseDb  
codeSpecs Accessor ReadOnly CodeSpecs BriefcaseDb Get the CodeSpecs in this IModel.
defaultLimit StaticReadonly "1000" BriefcaseDb  
dictionaryId StaticReadonly string BriefcaseDb The Id of the dictionary model.
ecefLocation Accessor undefined | EcefLocation BriefcaseDb The EcefLocation of the iModel in Earth Centered Earth Fixed coordinates.
If the iModel property geographicCoordinateSystem is not defined then the ecefLocation provides a geolocation by defining a
3D coordinate system relative to the Earth model WGS84. Refer to additional documentation for details. If the geographicCoordinateSystem
property is defined then the ecefLocation must be used with care. When the geographicCoordinateSystem is defined it indicates the
iModel cartesian space is the result of a cartographic projection. This implies a flattening of the Earth surface process that
results in scale, angular or area distortion. The ecefLocation is then an approximation calculated at the center of the project extent.
If the project is more than 2 kilometer in size, the ecefLocation may represent a poor approximation of the effective
cartographic projection used and a linear transformation should then be calculated at the exact origin of the data
it must position.
elements Readonly IModelDb.Elements BriefcaseDb  
fontMap Accessor ReadOnly FontMap BriefcaseDb  
geographicCoordinateSystem Accessor undefined | GeographicCRS BriefcaseDb The geographic coordinate reference system of the iModel.
globalOrigin Accessor Point3d BriefcaseDb An offset to be applied to all spatial coordinates.
holdsSchemaLock Accessor ReadOnly boolean BriefcaseDb determine whether the schema lock is currently held for this iModel.
iModelId Accessor ReadOnly string BriefcaseDb The Guid that identifies this iModel.
isBriefcase Accessor ReadOnly boolean BriefcaseDb override superclass method
isGeoLocated Accessor ReadOnly boolean BriefcaseDb True if this iModel has an EcefLocation.
isReadonly Accessor ReadOnly boolean BriefcaseDb Check if this iModel has been opened read-only or not.
isSnapshot Accessor ReadOnly boolean BriefcaseDb Returns true if this is a SnapshotDb
iTwinId Accessor ReadOnly string BriefcaseDb The Guid that identifies the context that owns this iModel.
GuidString | undefined for the superclass, but required for BriefcaseDb
key Accessor ReadOnly string BriefcaseDb Get the key that was used to open this iModel. This is the value used for Rpc and Ipc communications.
locks Accessor ReadOnly LockControl BriefcaseDb Get the LockControl for this iModel.
maxLimit StaticReadonly "10000" BriefcaseDb  
models Readonly IModelDb.Models BriefcaseDb  
name Accessor string BriefcaseDb Name of the iModel
onBeforeClose Readonly BeEvent<() => void> BriefcaseDb Event called when the iModel is about to be closed.
onChangesetApplied Readonly BeEvent<() => void> BriefcaseDb Event called after a changeset is applied to this IModelDb.
onEcefLocationChanged Readonly BeEvent<(previousLocation: undefined | EcefLocation) => void> BriefcaseDb Event raised after BriefcaseDb.ecefLocation changes.
onGeographicCoordinateSystemChanged Readonly BeEvent<(previousGCS: undefined | GeographicCRS) => void> BriefcaseDb Event raised after BriefcaseDb.geographicCoordinateSystem changes.
onGlobalOriginChanged Readonly BeEvent<(previousOrigin: Point3d) => void> BriefcaseDb Event raised after BriefcaseDb.globalOrigin changes.
onNameChanged Readonly BeEvent<(previousName: string) => void> BriefcaseDb Event raised after BriefcaseDb.name changes.
onOpen StaticReadonly BeEvent<(_args: OpenBriefcaseArgs) => void> BriefcaseDb Event raised just before a BriefcaseDb is opened.
onOpened StaticReadonly BeEvent<(_iModelDb: BriefcaseDb, _args: OpenBriefcaseArgs) => void> BriefcaseDb Event raised just after a BriefcaseDb is opened.
onProjectExtentsChanged Readonly BeEvent<(previousExtents: Range3d) => void> BriefcaseDb Event raised after BriefcaseDb.projectExtents changes.
onRootSubjectChanged Readonly BeEvent<(previousSubject: RootSubjectProps) => void> BriefcaseDb Event raised after BriefcaseDb.rootSubject changes.
openMode Accessor ReadOnly OpenMode BriefcaseDb The OpenMode used for this IModel.
pathName Accessor ReadOnly string BriefcaseDb Get the full path fileName of this iModelDb
projectExtents Accessor Range3d BriefcaseDb The volume, in spatial coordinates, inside which the entire project is contained.
relationships Accessor ReadOnly Relationships BriefcaseDb Get the linkTableRelationships for this IModel
repositoryModelId StaticReadonly string BriefcaseDb The Id of the repository model.
rootSubject Accessor RootSubjectProps BriefcaseDb The name and description of the root subject of this iModel
rootSubjectId StaticReadonly string BriefcaseDb The Id of the root subject element.
tiles Readonly IModelDb.Tiles BriefcaseDb  
txns Readonly TxnManager BriefcaseDb Manages local changes to this briefcase.
views Readonly IModelDb.Views BriefcaseDb  
workspace Accessor ReadOnly Workspace BriefcaseDb Get the Workspace for this iModel.

Defined in

Last Updated: 20 June, 2023