Database

A Database in DataBus corresponds to a space in APITable. A Database instance is usually stored as a single, from which the user can obtain various resources.


Methods

setDataStorageProvider

setDataStorageProvider(provider: IDataStorageProvider)

Set the data storage provider implementation for the database. After a Database is obtained from DataBus, the data storage provider for the database is automatically set by DataBus, The user often doesn’t need to modify it.

setStoreProvider

setStoreProvider(provider: IStoreProvider)

Set the store provider implementation for the database. After a Database is obtained from DataBus, the store provider for the database is automatically set by DataBus, The user often doesn’t need to modify it.

getDatasheet

getDatasheet(dstId: string, options: IDatasheetOptions): Promise<Datasheet | null>

Given a datasheet ID, obtain a datasheet from this database. If the datasheet does not exist, null is returned.

getDashboard

getDashboard(dsbId: string, options: IDashboardOptions): Promise<Dashboard | null>

Given a dashboard ID, obtain a dashboard from this database. If the dashboard does not exist, null is returned.

addEventListener

addEventHandler(handler: IResourceEventHandler): boolean

The Database supports installing custom event handlers. Events generated by resources obtained from a Database will be handled by event handlers installed on this Database.

If the same event handler has been added before, false is returned, otherwise, true is returned.

For the type of IResourceEventHandler, see Events.

removeEventHandler

removeEventHandler(handler: IResourceEventHandler): boolean

Remove an event handler from the database. If the event handler does not exist, false is returned, otherwise true is returned.

removeEventHandlers

removeEventHandlers(type: ResourceEventType)

Remove all event handlers of the given event type.

fireEvent

fireEvent(event: IResourceEvent): Promise<void>

Fire an event. All installed event handlers of the same type as the fired event will be called, in arbitrary order.