In-Memory Databases
Last updated
Last updated
In addition to using tables stored on real database servers, Servoy allows you to create In-Memory tables (using HSQL). These tables have the same configurations as regular database tables, including column properties and events.
You can populate these In-Memory tables by using a JSDataSet
and the createDataSource()
function. This function allows you to dynamically define In-Memory datasources or foundsets at runtime. If you've already defined the In-Memory table in Servoy Developer, you won’t need to provide the column and type information again, as this was already defined during design time.
There are two ways to create an In-Memory database:
Using the Solution Explorer context menu under Datasources -> In Memory -> Create new data source
. This opens a dialog where you can specify the datasource name.
After adding the datasource name, the Table Editor will open, allowing you to define the structure of your table, just like any other table.
At runtime, using JSDataSet::createDataSource.
This function allows you to dynamically define In-Memory datasources/foundsets at runtime. Alternatively, if you've already defined the In-Memory datasource in the Developer, you won’t need to provide column and type information at runtime, as it was set during design time.
In-Memory tables have an additional table event called onLoad, which is triggered when a form accesses the In-Memory datasource (i.e., when the form’s datasource is set to the In-Memory table) or when datasource.mem.name.getFoundSet() is called. This event enables you to populate the In-Memory datasource on demand, rather than during the solution or form’s onLoad
event.
However, you still need to use the JSDataSet::createDataSource() function within the onLoad method to actually populate the In-Memory table.
Below is a summary of available commands via the context menu for In-Memory datasources:
Deletes the In-Memory Datasource definition
Renames the In-Memory Datasource definition
Searches for all locations within the solution where the In-Memory datasource is used
Creates an In-Memory datasource with a specified name (table name). Opens the Table Editor to define and edit the table as you would for a regular database table.
Opens the Table Editor to edit the In-Memory table’s structure and column information (metadata stored by Servoy Developer).
Moves the In-Memory Datasource to another solution (module).
Deletes the In-Memory Datasource definition.
Renames the In-Memory Datasource definition.
Searches for all locations within the solution where the In-Memory datasource is used, and lists them in the ##Search view##. This can be useful to find out which objects are using this data source.
Opens the
Opens the to edit the table