ORM CoreAPI module
New implementation of the RHOM.
BETA VERSION - This API has not been officially released. It should not be used in a production environment. |
This API is part of the coreapi
extension that is included automatically.
:::ruby
extensions: [“coreapi”]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript.
If you are going to be using the JS ORM API, you’ll also need to include these lines in any files that will be using it:
<script type="text/javascript" charset="utf-8" src="/public/api/rhoapi-modules-ORM.js"></script> <script type="text/javascript" charset="utf-8" src="/public/api/rhoapi-modules-ORMHelper.js"></script> <script type="text/javascript" charset="utf-8" src="/public/api/rhoapi-modules-Ruby-RunTime.js"></script>
For Ruby access to the RHOM database please see the Rhom Ruby API guide.
Creates an ORM model reference.
Parameters
Enables Model Properties.
Possible Values :
If set then model is set for RhoConnect Sync.
(Default) Model will be of type propertyBag.
Model will be of type fixedSchema.
Instruct ORM to send all attributes to RhoConnect when an object is updated. By Default it is disabled.
RhoConnect provides a simple way to keep data out of redis. If you have sensitive data that you do not want saved in redis, add the pass_through option in settings/settings.yml for each source.
Used to create properties on your model.
The name of the property.
The type of property. Possible values are: String, Float, integer, Varchar, Blob. String is default.
Possible Values :
Overwrite client copy of blob with the new copy from server. This is useful when RhoConnect modifies images sent from Rhodes, for example zooming or cropping.
Sets the Behavior of this model. Possible ‘property’ options and the corresponding ‘value’s are passed as the parameter.
The partition to use for this model. Partitions can be used to segment the data and keep non-synched data separate from synched models.
Possible Values :
This partition is used automatically if the model is not a sync model.
This partition is used automatically if the model is a sync model.
This partition is used to store the application related information.
Sets the type of sync it will be.
Possible Values :
If data model is not a sync model.
Used when the data model is a sync model. Just syncs changes.
If the model is used only for bulk sync.
This number determines the order in which the models are processed and synchronised. Priority starts from lower value 1. Lower the number, higher is the priority. Default value is 1000.
To make the model Freezed.
This is used for data migration of the application.
Synchronous Return:
Method Access:
Rho.NewORM.addModel( Anoynomous Function methods)
Resets client info and sync models (optionally, local models as well)
Parameters
Whether or not to reset Local Models.
Synchronous Return:
Method Access:
Rho.NewORM.databaseClientReset(BOOLEAN resetLocalModels)
Rho::NewORM.databaseClientReset(BOOLEAN resetLocalModels)
Resets selected models, client info and local models.
Parameters
Whether or not to reset Client Info.
Whether or not to reset Local Models.
Synchronous Return:
Method Access:
Rho.NewORM.databaseFullReset(BOOLEAN resetClientInfo, BOOLEAN resetLocalModels)
Rho::NewORM.databaseFullReset(BOOLEAN resetClientInfo, BOOLEAN resetLocalModels)
Resets sync models, client info and local models and does the user logout.
Synchronous Return:
Method Access:
Rho.NewORM.databaseFullResetAndLogout()
Rho::NewORM.databaseFullResetAndLogout()
Resets selected models, client info and local models.
Parameters
List of models to reset.
Whether or not to reset Client Info.
Whether or not to reset Local Models.
Synchronous Return:
Method Access:
Rho.NewORM.databaseFullResetEx(ARRAY models, BOOLEAN resetClientInfo, BOOLEAN resetLocalModels)
Rho::NewORM.databaseFullResetEx(ARRAY models, BOOLEAN resetClientInfo, BOOLEAN resetLocalModels)
Resets sync models, client info and local models and does the user logout.
Synchronous Return:
Method Access:
Rho.NewORM.databaseFullclientResetAndLogout()
Rho::NewORM.databaseFullclientResetAndLogout()
Resets local database.
Synchronous Return:
Method Access:
Rho.NewORM.databaseLocalReset()
Rho::NewORM.databaseLocalReset()
Returns current Client Id.
Synchronous Return:
Method Access:
Rho.NewORM.getClientId()
Rho::NewORM.getClientId()
Returns TRUE whenever there are any local (non-synced) changes.
Synchronous Return:
Method Access:
Rho.NewORM.haveLocalChanges()
Rho::NewORM.haveLocalChanges()
Returns TRUE if NewORM is enabled in rhoconfig.txt.
Synchronous Return:
Method Access:
Rho.NewORM.useNewOrm()
Rho::NewORM.useNewOrm()
This example describes creating model and adding model object.
var Customer = function(model){ model.enable("sync"); model.setModelProperty("name","string",""); model.setModelProperty("brand","string",""); model.setModelProperty("price","float",""); model.set("partition","user"); model.set("schema_version",'1.1'); }; var custobj = Rho.ORM.addModel("Customer", Customer); // create model object and save it to database var customer = custobj.createObject({ brand: "Apple", name: "iPhone5", price: 199.99});
This example clears the local model’s passed through the array only. It doesn’t reset the client_info table.
var ary = ['Product','Product2']; Rho.ORM.databaseFullResetEx(ary, false, true);
ary = ['Product','Product2'] Rho.ORM.databaseFullResetEx(ary, false, true)