Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public with sharing class AuraUtils {
  2.  
  3. @AuraEnabled(cacheable=true)
  4. public static List<SObject> databaseQuery(String queryString){
  5. List<SObject> returnValue;
  6. try{
  7. returnValue = Database.query(queryString);
  8. } catch ( Exception e ){
  9. throw new AuraHandledException(e.getMessage());
  10. }
  11. return returnValue;
  12. }
  13.  
  14. import { LightningElement, api, wire, track } from 'lwc';
  15. import databaseQuery from '@salesforce/apex/AuraUtils.databaseQuery';
  16.  
  17. export default class UtilityDemo extends LightningElement {
  18.  
  19. @wire(databaseQuery, {queryString: '$accountQueryString'})
  20. accounts;
  21.  
  22. get accountQueryString () {
  23. return "SELECT Id, Name, Phone, (SELECT Id , FirstName, LastName FROM Contacts) FROM Account LIMIT 20";
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement