Accessing the database from scripts

The database nodes follow the node instance method described in Node classes and instances and the functionality can be accessed from objects obtained by using application.require() for the node.

For example, if your database node is located through the dynamic binding "database", you can get an object that accesses the database through the following.

var database = application.require(context.getBinding('database'));

Base class

The classes used for the database, table and row are all descended from a base class defined in Base Class Script. All the methods in the base class are available or overridden in the other classes. See the script for documentation.


The database node uses the database class defined in Database Class Script. This adds a getData() method that returns an array which contains details of all the tables in the database. See the script for documentation.

The base class getTable() method is often used with the database node to navigate to a particular table. For example, to get the product table you would use something like this.

var database = application.require(context.getBinding('database'));
var productTable = database.getTable('product');

You could then use the table API (below) on the returned table.


The table nodes use the table class defined in Table Class Script. This provides methods to create a new row and to query rows. It also provides methods to create or update multiple rows. See the script for documentation.

A common use would be to get a row object for a row identified by values of the key fields identied on the row type. For example, if your have a single product number field on your product row, you might get the row for product 123 using something like.

var productRow = product.getRowByKey(123);


The row nodes use the row class defined in Row Class Script. This provides methods to retrieve fields from the row, update the row and delete the row. See the script for documentation.

For example, to get the product_name field from a product row, and then update it, you might use something like this.

var oldProductName = product.getData().product_name;
product.patch({product_name: 'New product name'});