-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
salesforce
refactor query
function
#1030
Comments
Notes
Start from the code below 👇🏽 export function query(queryString, options = {}) {
return async state => {
const { connection } = state;
const [resolvedQuery, resolvedOptions] = expandReferences(
state,
queryString,
options
);
console.log(`Executing query: ${resolvedQuery}`);
// TODO: Add support for more query options
// https://jsforce.github.io/jsforce/types/query.QueryOptions.html
// {headers, responseTarget}
const {
autoFetch = true,
scanAll = false,
maxFetch = 10000,
} = resolvedOptions;
if (autoFetch) {
console.log(
`autoFetch is enabled: A maximum of ${maxFetch} records will be downloaded`
);
}
let query = {};
const records = [];
await new Promise((resolve, reject) => {
query = connection
.query(resolvedQuery)
.on('record', record => {
records.push(record);
})
.on('end', () => {
console.log('total in database : ' + query.totalSize);
console.log('total fetched : ' + query.totalFetched);
resolve();
})
.on('error', err => {
const { message, errorCode } = err;
console.error(`Error ${errorCode}: ${message}`);
throwError('QUERY_ERROR', { message, errorCode });
reject();
})
.run({ autoFetch, maxFetch, scanAll });
});
const result = {
done: query.totalFetched === query.totalSize,
records,
totalSize: query.totalSize,
totalFetched: query.totalFetched,
};
return composeNextState(state, result);
};
} |
Don't document jsforce options, just link to them :) Maybe if it's super commonly used then you can include it. Any options that WE provide that jsforce does NOT must be documented explicitly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The
query
function auto fetching implementation will no longer be needed on jsforcev3, Once we upgrade the adaptor to use the latest version of jsforcev3, See #1028, We should update the query function to useconn.query
See docs here also we should add support for queryOptions which will make it easy to auto fetch records when we hit the maximum fetch limit. See queryOptions hereThe text was updated successfully, but these errors were encountered: