The local database components represent data using JavaScript objects, serialised as JSON when using the REST API. You need to understand this format before you can access the database from scripts or through the REST API.
The data will contain data to identify each row, and data to identify linked rows. You also need to understand how this data is resolved to the row nodes that it represents.
Each row is held on a node. If you were to retrieve JSON for that node, it will always contain three fields: reference which contains the node reference, name which contains the node name, and url which contains the URL for the node. It will also contain the values for all the fields on the node, using the field short references as the property names. For example, a simple record holding product number and product name might look something like this.
{
"reference": "acme.sales.database.product._417223",
"name": "Fluffy teddy bear",
"url": "https://www.metrici.com/acme/sales/database/product/_417223",
"product_number": 417223,
"product_Name": "Fluffy teddy bear"
}
The root path for the URL is read from the database node itself. It is set automatically when the database node is instantiated. You can set it manually by editing the database node.
Each row also contains a timestamp_created field which indicates when the row was created.
No automated check is made to avoid two fields having the same short references, or that they do not coincide with the built in properties, reserved properties, or common REST parameters (which are reference, name, url, type, timestamp_created, timestamp_amended, action, filter, view, keys, pretty, boolean). If two fields have the same short reference, the outcome is not defined.
Links
A link to another row is represented by an object which contains reference, name and url. For example, if the product record linked to a range (a group of products), the JSON might look something like this.
{
"reference": "acme.sales.database.product._417223",
"name": "Fluffy teddy bear",
"url": "https://www.metrici.com/acme/sales/database/product/_417223",
"product_number": 417223,
"product_Name": "Fluffy teddy bear",
"range": {
"reference": "acme.sales.database.range.toys",
"name": "Toys",
"url": "https://www.metrici.com/acme/sales/database/range/toys"
}
}
Each row includes a type link which provides a link to its node type.
Children
Children are not included in the row unless they are specifically selected. Where they are, the children are returned as an array of objects containing the entire child rows (not just the reference, name and url). When returned with the row the link back to the parent is suppressed. For example, if you looked at the children of a range in the example above, you would get a list of products with product_number and product_name, but not with a range link.
Files
Files are represented in the same way as links. The file node uses the row node as a package. The file link URL will include the file extension. For example, a picture of a product might be held something like this.
"picture": {
"reference": "acme.sales.database.product._417223.teddy_bear",
"name": "teddy_bear.jpg",
"url": "https://www.metrici.com/acme/sales/database/product/_417223/teddy_bear.jpg"
}
Complex fields
Deprecated. This is currently unused and will be refactored to use the object and array types described in Node Data Script.
Complex fields are those that repeat, or use more than one of text, number and link. Complex fields are know as entity fields within the local database.
An entity field is represented by an array of objects. The objects will have properties for the text, number and link parts of the field. These will either be named based on the appropriate part caption property or as xxxx_yyyy, where xxxx is the field reference and yyyy is one of text, number or link.