Database Processing
The schema.process is a map of properties that control how data is stored in the database and how the data is processed.
The process
definitions define the following attributes:
- Where the database item will be stored: device / cloud / both.
- In what direction the database syncronization will flow: to-device / to-cloud / both.
- What metrics should be created from the data stream.
For each item type, you may define an entry in the process collection. For example:
Each map entry may contain the following properties:
Property | Type | Description |
---|---|---|
enable | string |
Control where the item is stored. Set to 'cloud' for in the cloud, 'device' for on the device and 'both' if in both locations. Defaults to 'both'. |
sync | string |
Define the direction of the data synchronization. Set to 'down' for down to the device, 'up' for up to the cloud, or 'both' for bi-directional. Defaults to null. |
metrics | Array |
Array of metric definitions. See below for details. |
notify | boolean |
Issue an AWS EventBridge notification event for matching data. Defaults to false. |
Database Synchronization
Ioto Device Tables takes the pain out of synchronizing device data into the cloud. It automatically and transparently synchronizes data between your devices and the cloud.
The database synchronization is full-duplex in that data can be modified in the device or in the cloud and it will be replicated to the other side. The synchronization is controllable on a per-item basis.
The "enable" property can be set to "cloud" if items of that type should exist only in the cloud database. Set the property to "device" if the items should exist only in the device. Set to "both" if they should exist in both databases. The default is "both".
The "sync" property defines the synchronization direction. Set to "up" to indicate the device data should be synchronized from the device up to the cloud. Set to "down" to indicate the cloud data should be replicated down to the device and set to "both" to replicate in both directions.
To design for effective synchronization, it is best to have the "sync" direction be either "up" or "down" and not "both". You should only select "both" for items that are not transactionally critical, as changes from the cloud or device may overwrite changes coming from the other directions.
Synchronization is done on a per-item basis and not field by field. This means that if you update a field in an item, the entire item will be updated on the peer side.
Metrics
For data that is synchronized to the cloud, you can create custom metrics from the data stream. These metrics can then be displayed or graphed in the Device Manager.
These metrics can be created by creating a Builder Automation action to trigger when specific data values are encountered.
Event Notification
For dedicated device clouds, you can issue AWS EventBridge events for matching database items via the notify property. The notify
property is set to the EventBridge bus name. It can be set to "default" or any custom EventBridge bus name.
The database item will be passed to the EventBridge bus as the event context data using the Embedthis/Ioto
as the event Source.
For example: