Class: sfStore

violetStoreSF~sfStore()

new sfStore()

Implements support for the core operations supported by Violet (for Force.com).
Source:

Methods

(static) delete(objName, keyName, keyVal) → {Promise}

Deletes given object in the underlying data store.
Parameters:
Name Type Description
objName string the object/table name in the data store where the give object is to be deleted
keyName string the key name to find the object to be deleted
keyVal Object the key value to find the object to be deleted
Source:
Returns:
Promise that resolves when the data has been deleted in the store
Type
Promise
Example
resolve: function *(response) {
  var caseObj = ...
  yield response.delete('Case*', 'CaseNumber*', caseObj.CaseNumber);
  response.say( `Case ${caseObj.Subject} has been removed`);
}

(static) load(queryParams) → {Promise}

Retrieves given object from the underlying data store.
Parameters:
Name Type Description
queryParams Object query parameters
Properties
Name Type Description
objName string the object/table name in the data store where the give object is to be updated
keyName string the key name to find the object to be updated
keyVal string the key value to find the object to be updated
query string the SOQL query, i.e. what gets executed is "SELECT "
filter string additional query results filter - this is added to the end of the SQL query
queryXtra string additional bits to be added to the end of the query, for example "LIMIT 100". "LIMIT 100" is auto added. Use false to prevent auto adding, for example when using aggregate queries.
Source:
Returns:
Promise that resolves with the data
Type
Promise
Examples

performing a raw (SOQL) query

resolve: function *(response) {
  var results = yield response.load({
    query: "CreatedDate, Status__c, Verified__c FROM Automated_Tests__c WHERE Status__c = 'New'  limit 100"
  });
  response.say(`Found ${results.length} tests`);
});

query with parameters as needed

violetSFStore.store.propOfInterest = {
  'Automated_Tests': ['Name*', 'Status', 'Verified']
};
...
resolve: function *(response) {
  var results = yield response.load({
    objName: 'Automated_Tests',
    keyName: 'Status',
    keyVal: 'New'
  });
  response.say(`Found ${results.length} tests`);
});

basic query

violetSFStore.store.propOfInterest = {
  'Automated_Tests': ['Name*', 'Status', 'Verified']
};
...
resolve: function *(response) {
  var results = yield response.load('Automated_Tests', 'Status', 'New');
  response.say(`Found ${results.length} tests`);
});

(static) search(objName, searchStr) → {Promise}

Does a search
Parameters:
Name Type Description
objName string the object/table name which is to be searched
searchStr string the search string to look up
Source:
Returns:
Promise that resolves when the data has been found
Type
Promise
Example
violetSFStore.store.propOfInterest = {
 'KnowledgeArticleVersion*': ['Id*', 'Title*', 'Summary*', 'UrlName*', 'LastPublishedDate*']
}
...
yield violetSFStore.store.search('KnowledgeArticleVersion*', 'security')

(static) store(objName, dataToStore) → {Promise}

Adds given object to the underlying data store.
Parameters:
Name Type Description
objName string the object/table name in the data store where the give object is to be stored
dataToStore Object the object to be written (i.e. a set of key:value pairs)
Source:
Returns:
Promise that resolves when the data has been written in the store
Type
Promise
Example
resolve: function *(response) {
  var caseObj = ...
  yield response.store('CaseComment*', {
    'CommentBody*': 'Text String',
    'ParentId*': caseObj.Id
  });
  response.say(`Case ${caseObj.Subject} has comment added`);
}

(static) update(objName, keyName, keyVal, updateData) → {Promise}

Updates given object in the underlying data store.
Parameters:
Name Type Description
objName string the object/table name in the data store where the give object is to be updated
keyName string the key name to find the object to be updated
keyVal Object the key value to find the object to be updated
updateData Object the object values to be updated (i.e. a set of key:value pairs)
Source:
Returns:
Promise that resolves when the data has been updated in the store
Type
Promise
Example
resolve: function *(response) {
  var caseObj = ...
  yield response.update('Case*', 'CaseNumber*', caseObj.CaseNumber, {
      'Priority*': response.get('casePriority')
  });
  response.say( `Case ${caseObj.Subject} has priority updated to [[casePriority]]`);
}
Documentation generated by JSDoc 3.5.5 on Mon Jul 23 2018 23:46:45 GMT-0400 (EDT)