The RhoMobile Suite provides several APIs for handling device data. Released with RhoMobile Suite 5.3 is the ORM common API, which supports JavaScript and Ruby. Pay attention to ORM Common API has not been officially released. It should not be used in a production environment.
RMS 5.2 and earlier versions support the original Rhom API for Ruby apps and the ORM API, which adds JavaScript support to Rhom via the OPAL library.
RMS 5.3 and higher:
RMS 5.2 and lower:
Documentation:
The ORM common API exposes more methods to JavaScript than the ORM API, and is therefore recommended for building new JavaScript apps. Ruby developers can use Rhom or the ORM common API. |
In general computing, ORM refers to the object-relational mapping technique that permits records of a relational database to be stored and retrieved programatically as objects. For RhoMobile, the ORM API provides a powerful high-level interface to an on-device SQLite database that can work alone or with the RhoConnectClient to enable two-way synchronization between your application and a RhoConnect server.
One of the main benefits of using an ORM is the simplicity it brings to database operations. Instead of having to write complex SQL statements by hand, an app can perform database actions by getting and setting properties on model objects. For example:
Update a record with a SQL command:
update product set price=119,brand='Symbol' where object='12345'
Update the same record with ORM:
product.updateAttibutes({price: 119, brand: "Symbol"});
Delete a record with SQL:
delete from product where object='12345'
Delete an object with ORM:
product.destroy();
In general, RhoMobile applications follow the Model-View-Controller (MVC) pattern. In RhoMobile, a model can store information from two sources:
Each model contains attributes (aka ‘fields’) that store information relating to that model. For example, a Product
model might have the attributes of name
, brand
and price
. Applications will normally have a model for each entity that they handle (i.e. Customer
, Product
, Invoice
, InvoiceLine
, Order
, LineItem
, etc).
RhoMobile apps can use two kinds of models:
Each model type has advantages and disadvantages depending on the application.
In the property bag model, data is stored as key-value pairs in a single table using the object-attribute-value or entity-attribute-value model. This model is sometimes referred to as ‘open schema’ because the fields (or keys) do not have to be defined in advance; the API stores and syncs all key-value pairs that are entered.
In a fixed schema model, each model has a separate database table and attributes forms the columns of that table. In this sense, the fixed schema model is similar to a traditional relational database.
By default, RhoMobile apps will be built to use the older Rhom implementation (for Ruby) and ORM implementation (for JavaScript). To activate the newer ORM Common API (which supports both JavaScript and Ruby), add the following line to application’s rhoconfig.txt
file:
use_new_orm = 1
Possible Values:
If this parameter is left unspecified, the older Rhom/ORM API will be used. |
New ORM API is still experimental and is not guaranteed to work correctly with Ruby. Use at your own risk. |
If your application requires local (on-device) database encryption, enable it by setting a flag in build.yml
:
encrypt_database: 1
If you are using RMS with version lesser than 6.0.58 and want to update your application with a version, built on newer RMS version, and you don’t want to database be automatically clean - you should enable a flag in build.yml
:
use_deprecated_encryption: 1
Database encryption is not currently supported for applications that use bulk sync.
Rhom data encryption is no longer available as of Rhodes 3.3.3 and higher.