uniface.datastore

The uniface.datastore API provides access to the local browser-based database used for client-side data storage.

For more information, see Client-Side Data Storage.

Functions

Datastore Functions

Function

Description

put()

Creates or updates a JSON document in a client-side database.

get()

Retrieves the specified JSON object from a client-side database.

remove()

Deletes the specified JSON document from a client-side database.

Promises and Errors

All of these functions return a JavaScript Promise, such as the specified JSON document or a response. If the Promise cannot be fulfilled, an error or exception is returned. The most common errors are:

  • 409 conflict errors are returned when the database is unable to commit an action such as a put() or remove(), for example, a JSON document already exists with a specified _id, or when a specified _rev value does not match.
  • 404 not found exceptions, which are returned when an attempt is made to retrieve data that does not exist. Such an exception might look like this:
    {
     status: 404,
     name: "not_found",
     message: "missing",
     error: true,
     reason: "missing",
    }
    

You should always provide error handling for errors and exceptions. For example:

var myDoc = {
  _id: 'someid',
  _rev: '1-somerev'
};
uniface.datastore.put(myDoc).then(function () {
  // success
}).catch(function (err) {
  if (err.name === 'conflict') {
    // conflict!
  } else {
    // some other error
  }
});

Related Topics