Allows access to the Rhodes mini database object mapper, performing database operation on Rhodes model objects. See the Rhom examples for examples of the Rhom API.
As of Rhodes version 3.3.3, the Barcode, NFC, and Signature Capture APIs, as well as Rhom data encryption are removed from Rhodes. These features are only supported in Zebra RhoMobile Suite. If you wish to use these features, you will need to upgrade to RhoMobile Suite. Your application’s build.yml will also need to be modified to indicate the application type is ‘Rhoelements’. Additionally, a RhoElements license is required.
Returns the current sync client id.
modelname.client_id
Clear notification for the object. See the sync notification section for more details.
modelname.clear_notification
Creates a zip archive of a local database partition with all its blob objects, and returns a path to that zip archive.
Rhom::Rhom.database_export(partition)
partition |
a local database partition. |
Imports the database and blob objects from a zip archive created with database_export
. If the imported archive is inconsistent, or other failure occurs during the import process, the original database will be restored.
Rhom::Rhom.database_import(partition, path_to_zip)
partition |
the local database partition to be replaced by the zip. |
path_to_zip |
path to the zip archive created with database_export. |
Delete all Rhodes model objects for a source, filtering by conditions. Click here for a Rhom delete_all example.
modelname.delete_all(:conditions, :op)
:conditions |
(optional) hash of attribute/values; delete only objects matching these criteria, such as :conditions => {'industry'=>'electronics'} . |
:op |
(optional) operator, such as "OR" or "IN". Allows you to have more than one set of conditions. |
Destroy a Rhodes model object. Click here for a Rhom destroy example.
modelname.destroy
Find Rhodes model objects. Click here for a Rhom find example.
modelname.find(argument list)
The argument list can consist of the following arguments.
:all |
returns all objects; can use optional :conditions . |
:first |
returns first object matching :conditions . |
:count |
returns the number of objects matching these :conditions . |
:conditions |
(optional) hash of attribute/values. Also supports sql fragments (i.e. "name like 'rhomobile'") or sql fragment with binding (you have to define :select with sql queries) (i.e. ["name like ?", "'#{company#}'"]) Use a comma around string values. |
:order |
(optional) attribute(s) to order the list. |
:orderdir |
(optional) Order direction: 'ASC' ascending, 'DESC' descending. Default = 'ASC'.) |
:select |
(optional) array of string attributes to return with the object. Useful if your model has many attributes and your query only needs a few of them. |
:per_page |
(optional) maximum number of items to return. |
:offset |
(optional) offset from beginning of the list. |
:op |
(optional) operator, such as "OR" or "IN". Allows you to have more than one set of conditions. |
For examples of find with advanced queries, see Advanced Queries in Using the Local Database with Rhom.
Alias for modelname.find(:all, argument list).
Returns Rhodes model object(s) based on sql_query. This method works only for schema models. Click here for a Rhom find_by_sql example.
modelname.find_by_sql(sql_query)
sql_query |
An sql query, such as "SELECT * FROM Account" . |
Returns the source id number for this Rhodes model object.
modelname.get_source_id
Returns the source name for this Rhodes model object.
modelname.get_source_name
Create a new Rhodes model object. Rhom new example.
modelname.new(attributes)
attributes |
List of attributes assigned to the new model object, such as {"name" => "ABC Inc.","address" => "555 5th St."} . |
Create a new Rhodes model object and save it to the database.Rhom create example.
This is the fastest way to insert a single item into the database.
modelname.create(attributes)
attributes |
List of attributes assigned to the new model object, such as {"name" => "ABC Inc.","address" => "555 5th St."} . |
Call find
with a limit on the number of records. Default page size is 10.Rhom paginate example.
modelname.paginate(*arguments)
The *arguments you can use are:
:page |
which page to return. |
:per_page |
with :page (used as offset), the number of records to return, such as :page => 1, :per_page => 20
|
:conditions |
same as find with :conditions
|
:order |
same as find with :order
|
:select |
same as find with :select
|
Start the sync process for a Rhodes model. Click here for a Rhom sync example.
modelname.sync(callback_url, callback_data, show_status_popup, query_params)
callback_url |
the url for the sync callback method. If this is used, SyncEngine.set_notification is called before SyncEngine.dosync. |
callback_data |
Data for the callback method. |
show_status_popup |
true if you want to show a popup window upon sync, false otherwise. |
query_params |
Optional. a query to pass to the sync server. The query_params value must be URL encoded. |
Returns true if the Rhodes model object is not currently being synced (if it is being synced, you should disable editing of the object). Click here for a Rhom can_modify example.
Before displaying an edit page for an object, your application can check if the object is currently being accessed by the sync process. If it is, you should disable editing of the object. can_modify
could return true, for example, on a new local record that was created and sent to the RhoConnect application, but no response has been received yet.
modelname.can_modify
Returns true if a Rhodes model object has local database changes that need to be synchronized, false otherwise. Click here for a Rhom changed? example.
modelname.changed?
Saves the current Rhodes model object to the database. Click here for a Rhom save example.
modelname.save
Set a notification to be called when the sync is complete for this model. Click here for a Rhom set_notification example.
modelname.set_notification(callback_url, params)
callback_url |
the url for your sync is finished notification callback method. |
params |
parameters for the callback method. |
Updates the current Rho model object attributes and saves it to the database. This is the fastest way to add or update model attributes. Click here for a Rhom update_attributes example.
modelname.update_attributes(attributes)
attributes |
List of attributes and their updated values, such as {"name" => "ABC Inc.","address" => "555 5th St."} . |
Reset the Rhodes model database and logout. Equivalent to Rhom::Rhom.database_full_reset(true)
followed by SyncEngine.logout
.
Deletes all records from the property bag and model tables. For examples, see Resetting the Database in Using the Local Database with Rhom.
Rhom::Rhom.database_full_reset(reset_client_info, reset_local_models)
reset_client_info |
true to clean the client_info table, false otherwise. |
reset_local_models |
true to clean local (non-synced) models, false otherwise. |
Perform a full reset, then logout the RhoConnect client.
Rhom::Rhom.database_full_reset_and_logout
Reset only local (non-sync-enabled) models.
Rhom::Rhom.database_local_reset
Returns the metadata definition for a given model as a hash. Click here for a Rhom metadata example.
Product.metadata #=> {'foo' => 'bar'}
Assigns the JSON metadata definition for a given model. Click here for a Rhom metadata example.
Product.metadata = { 'foo' => 'bar' }.to_json
metadata_def |
JSON string of the metadata definition |