Created
July 15, 2022 12:10
-
-
Save sjurgis/b926f5ce03ae118ba04b8da40193ab87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getByNames from '@salesforce/apex/OpportunitiesSelector.getByNames'; | |
export default class Operatunity extends LightningElement { | |
async connectedCallback() { | |
const [contacts, accounts, opportunities] = await getByNames({names: ['foo', 'bar', 'qux']}) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class OpportunitiesSelector { | |
@AuraEnabled public static Object[] getByNames(String[] names) { | |
Contact[] contacts = [SELECT Id FROM Contact WHERE Name = :names]; | |
Account[] accounts = [SELECT Id FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Id = :contacts)]; | |
Opportunity[] opportunities = [SELECT Id FROM Opportunity WHERE AccountId = :accounts]; | |
return new Object[]{ | |
contacts, | |
accounts, | |
opportunities | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment