Saving Data Objects
|Top Previous Next|
The API to save an object can be used for two separate scenarios: if an object has been previously saved, it is updated in the data store, otherwise it is saved (created). The save operation checks if the object has objectId assigned by the server. in that case, the object is updated, otherwise it is created in the Backendless data store. In case when there is no table for the persisted object, Backendless creates one and maps table's columns to the object's properties.
The objectId property is automatically assigned to all persisted objects when they are initially saved. See the Data Object section for details on objectId.
Backendless.Persistence.of( constructor-function ).save( entity, async )
If the method is invoked synchronously, it returns the saved object. The asynchronous call receives the return value through a callback executed on the Async object.
Consider the following class:
The following code saves a new instance of the Contact class: