Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class AuraUtils {
- @AuraEnabled(cacheable=true)
- public static List<SObject> databaseQuery(String queryString){
- List<SObject> returnValue;
- try{
- returnValue = Database.query(queryString);
- } catch ( Exception e ){
- throw new AuraHandledException(e.getMessage());
- }
- return returnValue;
- }
- import { LightningElement, api, wire, track } from 'lwc';
- import databaseQuery from '@salesforce/apex/AuraUtils.databaseQuery';
- export default class UtilityDemo extends LightningElement {
- @wire(databaseQuery, {queryString: '$accountQueryString'})
- accounts;
- get accountQueryString () {
- return "SELECT Id, Name, Phone, (SELECT Id , FirstName, LastName FROM Contacts) FROM Account LIMIT 20";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement