Retrieving Data
To pull data from Salesforce, each RestObject provides a static retrieve
function.
SObject.retrieve(qry, opts?)
SObject.retrieve(qry, opts?)
import { Account } from './generated';
const accounts = await Account.retrieve(
'SELECT Id, Name FROM Account LIMIT 1'
);
//using query builder (recommended)
const accounts = await Account.retrieve(f => ({
select: f.select('id','name'),
limit: 1
}));
// explicitly setting the Rest client
const accounts = await Account.retrieve(
'SELECT Id, Name FROM Account LIMIT 1',
{ restInstance: someOtherOrg }
);
This function returns the entire result set by automatically making additional requests until all rows have been returned. Be careful when operating on large datasets and use the LIMIT
clause accordingly.
Opts
Key
Type
Description
restInstance
Rest
The Rest
client to retrieve data from. If not set, "default" client is used. See Connecting with Salesforce
useComposite
boolean
Experimental! Uses the composite API to reduce the number of queries and in theory offer better performance. NOTE: It seems Salesforce has started throttling queries made this way and thus it is not recommended to use this setting at this time.
Last updated
Was this helpful?