Methods
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 |
Returns:
Promise that resolves when the data has been deleted in
the store
- Type
- Promise
Example
resolve: function *(response) {
var caseObj = ...
yield response.update('Case', 'CaseNumber', caseObj.CaseNumber);
response.say( `Case ${caseObj.Subject} has been removed`);
}
load(queryParams) → {Promise}
Retrieves given object from the underlying data store.
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
queryParams |
Object | query parameters
Properties
|
Returns:
Promise that resolves with the data
- Type
- Promise
Examples
performing a raw (SQL) query
resolve: function *(response) {
var results = yield response.load({
query: "CreatedDate, Status, Verified FROM Automated_Tests WHERE Status = '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`);
});
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) |
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`);
}
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) |
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]]`);
}