diff --git a/ast.json b/ast.json index cfe09a0..8b2af15 100644 --- a/ast.json +++ b/ast.json @@ -196,7 +196,6 @@ "name": "query", "params": [ "qs", - "callback", "state" ], "docs": { @@ -226,15 +225,6 @@ }, "name": "qs" }, - { - "title": "param", - "description": "A callback to execute once query is done", - "type": { - "type": "NameExpression", - "name": "Function" - }, - "name": "callback" - }, { "title": "param", "description": "Runtime state.", diff --git a/lib/Adaptor.js b/lib/Adaptor.js index 510c0db..0946d99 100644 --- a/lib/Adaptor.js +++ b/lib/Adaptor.js @@ -266,13 +266,12 @@ const retrieve = (0, _lodashFp.curry)(function (sObject, id, callback, state) { * query(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`); * @constructor * @param {String} qs - A query string. - * @param {Function} callback - A callback to execute once query is done * @param {State} state - Runtime state. * @returns {Operation} */ exports.retrieve = retrieve; -const query = (0, _lodashFp.curry)(function (qs, callback, state) { +const query = (0, _lodashFp.curry)(function (qs, state) { let { connection } = state; @@ -284,11 +283,9 @@ const query = (0, _lodashFp.curry)(function (qs, callback, state) { } console.log('Results retrieved and pushed to position [0] of the references array.'); - const nextState = { ...state, + return { ...state, references: [result, ...state.references] }; - if (callback) return callback(nextState); - return nextState; }); }); /** diff --git a/src/Adaptor.js b/src/Adaptor.js index 7dc8edf..febbe9d 100644 --- a/src/Adaptor.js +++ b/src/Adaptor.js @@ -114,11 +114,10 @@ export const retrieve = curry(function (sObject, id, callback, state) { * query(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`); * @constructor * @param {String} qs - A query string. - * @param {Function} callback - A callback to execute once query is done * @param {State} state - Runtime state. * @returns {Operation} */ -export const query = curry(function (qs, callback, state) { +export const query = curry(function (qs, state) { let { connection } = state; qs = expandReferences(qs)(state); console.log(`Executing query: ${qs}`); @@ -132,9 +131,10 @@ export const query = curry(function (qs, callback, state) { 'Results retrieved and pushed to position [0] of the references array.' ); - const nextState = { ...state, references: [result, ...state.references] }; - if (callback) return callback(nextState); - return nextState; + return { + ...state, + references: [result, ...state.references], + }; }); });