Version: Smart Feature Phone 2.5
DataStore.add()
The add() method of the DataStore interface adds a new record to the data store; if the record you are attempting to add already exists, it will throw an exception.
Syntax#
Returns#
A Promise object of type DataStoreKey that resolves with a ID number identifying the record added to the store.
Parameters#
object
The object you want to add to the data store.id
You can specify an optional second parameter that will be aDataStoreKeyof type unsigned long orDOMString, if you want to give the added record a specific id. If you don't specify this, the object's id will be numeric (auto incremented).revisionId
You can specify an optional third parameter that will be a revisionId (aDOMString). This can be used to prevent conflicts. If therevisionIdis not the currentrevisionIdfor the current Data Store, the operation is aborted. This means that the developer has a 'old'revisionIdand will have to manage the conflict somehow.
Example#
The following example function takes the current data store and an object to be added to the data store as arguments, adds the object to the store, and then creates a table row to display the object data in the app and appends it to an existing table in the DOM: