Rhom is a database object mapper or ORM for RhoMobile. It provides a simple but powerful high level interface to use a local (on-device) SQLite database in terms of objects, and works hand in hand with RhoConnectClient to enable two-way synchronization between your application and a RhoConnect server.
One of its main benefits is that, instead of having to write SELECT and UPDATE statements by hand, you can carry out actions in your database by getting and setting properties on model objects.
Without Rhom, you would issue SQL statements to the database:
update product set price=119,brand='Motorola' where object='12345'
With Rhom you can achieve the same result with: :::javascript product.updateAttibutes({price: 119, brand: “Zebra”});
Object deletion in SQL:
delete from product where object='12345'
Object deletion with Rhom:
product.destroy();
RhoMobile applications, in general, follow the Model-View-Controller (MVC) pattern. In RhoMobile, a model can store information from two origins:
Each model contains attributes that it stores information about. For example, a Product
model could have as attributes name
, brand
, price
, etc. Applications will normally have one model for each entity they handle (Customer
, Product
, Invoice
, InvoiceLine
, Order
, LineItem
, etc).
There are two types of models used with RhoMobile applications: Property Bag and Fixed Schema. Each of them are useful under different conditions. Be sure to consider the points below when chosing which scheme you wish to use in your application.
In a property bag model, all data is stored in a single table using the object-attribute-value pattern also referred to as the Entity-attribute-value model. This data is schemaless, which means that you don’t need to specify ahead of time what keys exist on each ORM Model. You simply set whatever key-value pairs you want, and Rhom will store and sync it.
In a fixed schema model, each model has a separate database table and each attribute exists as a column in the table. In this sense, fixed schema models are similar to traditional relational tables.
RhoMobile applications provide definition and CRUD access to your data models in both Ruby and JavaScript, however there are some differences in capabilties between the two. Please consult the API reference and guides for further information:
As of Rhodes version 3.3.3, Rhom data encryption is removed from Rhodes. This feature is only supported in Zebra RhoMobile Suite. If you wish to use this feature, you will need to upgrade to RhoMobile Suite purchase a RhoElements license is required.
If your application requires that the local database is encrypted on the filesystem, you can enable it by setting a flag in build.yml
:
encrypt_database: 1
Database encryption is not supported for applications that use bulk sync at this time.