Skip to content

Retrieving Data

Charlie Jonas edited this page Nov 14, 2018 · 3 revisions

Each generated class contains a static retrieve method that makes it simple to execute SOQL commands against the object. The retrieve method returns a Promise with an array of the results (EG: Promise<Contact[]>).

(async()=>{ //async anonymous self-invoking function so we can use async/await :)
    //put all example code inside here

    let contacts = await Contact.retrieve(`SELECT Email, Account.Name, Account.Name__c FROM Contact LIMIT 10`);
    console.log(contacts.length);

})().then(()=>console.log('done!'))

Add and run the following code (if you don't have any contacts in your org, create some test data to work with).

Clone this wiki locally