db Object
  • Updated on 17 Aug 2019
  • 1 minute to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

db Object

  • Print
  • Share
  • Dark
    Light

The db Object can be accessed from within the state Object and offers a number of methods to perform operations in local and iCloud persistent storages.

Methods

getDataFromIndex(index, queryString, pageSize, sort)

This method returns data from a given index in the storage of a Cloud database.

queryString = {
   field: value
};
return state.db.getDataFromIndex('testindex', queryString)
    .then(response => {
        //Process response
    });

countDataInIndex(index, queryString)

This method counts the number of rows matching the queryString in an index.

queryString = {
   field: value
};
 return state.db.countDataInIndex('testindex', queryString)
    .then(response => {
        //Process response
    });

writeDataIntoIndex(index, docType, doc)

This method stores JSON documents in an index.

return state.db.writeDataIntoIndex('testindex', 'test', {test: 'doc'})
      .then(response => {
        state.addStringResponse('Data saved');
    });
Was this article helpful?