WorkspaceDb Interface

A SQLite database in a Workspace containing named resources that the application is configured to use. Resources are referred to by their WorkspaceResourceNames and can represent any number of things, including:

Ultimately, each resource is stored in one of the following formats:

  • A string, which is often a stringified JSON representation of the resource;
  • A binary blob; or
  • An embedded file.

Strings and blobs can be accessed directly using getString and getBlob. Files must first be copied to the local file system using getFile, and should be avoided unless the software that uses them is written to access them from disk.

A WorkspaceDb resides in a WorkspaceContainer that can be published to the cloud. Once published, the WorkspaceDb becomes immutable. However, multiple versions of a single WorkspaceDb can be created, allowing the Workspace contents to evolve over time. WorkspaceDbs use semantic versioning.

The set of available WorkspaceDbs available for use for specific purposes are defined in the Workspace's Settings. You can obtain a single WorkspaceDb using getWorkspaceDb, but more commonly you will use getWorkspaceDbs to obtain a list of all of the WorkspaceDbs, sorted by priority, that correspond to a given SettingName.

You can create new WorkspaceDbs (or new versions of existing WorkspaceDbs) using WorkspaceEditor.

Methods

Name Description
close(): void Close the underlying sqliteDb.  
getBlob(rscName: string): undefined | Uint8Array Look up a binary resource by name, if one exists.  
getFile(rscName: string, targetFileName?: string): undefined | string Extract a local copy of a file resource from this WorkspaceDb, if present.  
getString(rscName: string): undefined | string Look up a string resource by name, if one exists.  
open(): void Open the underlying sqliteDb to perform a query.  
prefetch(opts?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch Ensure that the contents of this WorkspaceDb are downloaded into the local cache so that it may be accessed offline.  
queryResources(args: WorkspaceDbQueryResourcesArgs): void Find resources of a particular type with names matching a specified pattern.  

Properties

Name Type Description
container Readonly WorkspaceContainer The WorkspaceContainer in which this db resides.  
dbFileName Readonly string The name by which the WorkspaceDb can be opened.  
dbName Readonly string The base name of this WorkspaceDb, without version  
isOpen Readonly boolean Whether the underlying sqliteDb is currently opened.  
manifest Readonly WorkspaceDbManifest The manifest that describes the contents and context of this WorkspaceDb.  
onClose Readonly BeEvent<() => void> An event raised before this WorkspaceDb is closed.  
sqliteDb Readonly SQLiteDb The underlying SQLite database that stores this WorkspaceDb's resources.  
version Readonly string The version of this WorkspaceDb  

Defined in

Last Updated: 14 November, 2024