ViewStore Namespace

A ViewStore is a database that stores Views and related data. It is used to store and retrieve views for iTwin.js. It can either be a local SQLite file, or a CloudSqlite database stored in a cloud container. To use a CloudSqlite database, you must first create a container in Blob Storage and then call ViewStore.CloudAccess.initializeDb.

A ViewStore can hold:

  • Views
  • DisplayStyles
  • CategorySelectors
  • ModelSelectors
  • RenderTimelines
  • Searches
  • Tags
  • Thumbnails
  • ViewGroups

Views are added to a ViewStore via ViewDefinitionProps that may hold references to a DisplayStyle, CategorySelector, ModelSelector, or RenderTimeline. Before storing a View, you must first add any referenced DisplayStyles, CategorySelectors, ModelSelectors, and RenderTimelines to the ViewStore. The "add" methods return a string that uniquely identifies the object in the ViewStore. You should set the ViewDefinitionProps's displayStyle, categorySelector, modelSelector, or renderTimeline member to the returned string. When you load a ViewDefinition from the ViewStore, the member may be used to load the DisplayStyle, CategorySelector, ModelSelector, RenderTimeline, etc.

A IdString is a string that uniquely identifies a row in one of the ViewStore's internal tables. The string holds a base-36 integer that starts with "@" (vs. "0x" for ElementIds). For example, if you store a DisplayStyle and it is assigned the ViewStore Id "@y1", then you should set the ViewDefinitionProps's displayStyle member to "@y1". When you load the ViewDefinition from the ViewStore, the "@Y1" may be used to alo load the DisplayStyle from the ViewStore.

Views are organized into hierarchical ViewGroups (like file and folder hierarchies on a file system). A View is always stored "in" a ViewGroup, and views must have a name that is unique within the ViewGroup. ViewGroups may each have a default ViewId. The root ViewGroup is named "Root" and has a RowId of 1. The root ViewGroup can not be deleted. View names and ViewGroup names may not contain either "/" or "@". ViewGroups are stored in the "viewGroups" table.

Views may be "tagged" with one or more Tags. Tags are named with an arbitrary string that can be used to group Views. A Tag may be associated with multiple Views, and a View may have multiple Tags. Tags are stored in the "tags" table.

Views may optionally have a thumbnail, paired via the View's Id. Thumbnails are stored in the "thumbnails" table.

Note: All ElementIds and ModelIds in ModelSelectors, CategorySelectors, DisplayStyles, Timelines, etc. are converted to guid-based identifiers when stored in the ViewStore. They are then remapped back to their Ids when loaded from the ViewStore. This allows the ViewStore to be used with more than one iModel, provided that the same Guids are used in each iModel. This is done by storing the set of unique Guids in the "guids" table, and then creating a reference to the row in the "guids" table via the special Id prefix "^". For example, if a category selector contains the Id "0x123", then the guid from element 0x123 is stored in the "guids" table, and the category selector is stored with the rowId of the entry in the guid table (e.g. "^1w"). When the category selector is loaded from the ViewStore, the guid is looked up in the "guids" table and the iModel is queried for the element with that guid. That element's Id (which may or may not be 0x123) is then returned in the category selector.

Class

Name Description
ViewStore.CloudAccess Provides access to a cloud-based ViewDb
ViewStore.ViewDb  

Interface

Name Description
ViewStore.CreateNewContainerProps  
ViewStore.ReadMethods methods of cloud ViewDb for read access
ViewStore.ViewDbCtorArgs  

Type alias

Name Description
ViewStore.RowId A row in a table.
ViewStore.ViewStoreCtorProps arguments to construct a ViewStore.CloudAccess

Variable

Name Description
ViewStore.defaultViewGroupId  
ViewStore.tableName  

Function

Name Description
ViewStore.fromRowId convert a RowId to a RowString (base-36 integer with a leading "@")

Defined in

Last Updated: 14 November, 2024