function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anil Kumaranil Kumar 

how to show child query count in lightning component

Hi All,

I have to show child query count in aura:iteration. Could anyone help me how to  show child query count ?

Below is apex controller:

public without sharing class BH_LocationsListClass {
       @AuraEnabled
        public static List<SVMXC__Site__c>  findAll() {
            
            id persAccId; 
            Set<id> BusAcc = new Set<id>();
            set<id> Locid = new set<id>();
            List<id> SiteIds = new List<id>();
            persAccId = [SELECT AccountID FROM User WHERE id = :  UserInfo.getUserId()].AccountID;//0050V0000070hym  UserInfo.getUserId()
            List<Person_Account_Location_Association__c> AsscoBusList = [select BH_Business_Account__c from Person_Account_Location_Association__c where BH_Person_Account_Association__c =:persAccId];
            system.debug('Account ID '+ persAccId);
                    if(AsscoBusList.size()>0){
            for(Person_Account_Location_Association__c mainAcc : AsscoBusList){
                BusAcc.add(mainAcc.BH_Business_Account__c);
            }
        }
        List<SVMXC__Site__c>  SiteList = [select name from SVMXC__Site__c where SVMXC__Account__c in:BusAcc];
        for(SVMXC__Site__c sites :SiteList){
            SiteIds.add(sites.id);
        }
        List<Person_Account_Location_Association__c> AsscolIst = [select BH_Location_Association__c from Person_Account_Location_Association__c where BH_Person_Account_Association__c =:persAccId and BH_Location_Association__c in: SiteIds];
        system.debug('AsscolIst common'+AsscolIst);
        
        if(AsscolIst.size()>0){
            for(Person_Account_Location_Association__c mainAcc : AsscolIst){
                Locid.add(mainAcc.BH_Location_Association__c);
            }
        }
        system.debug('Locid common'+Locid);
            
        List<SVMXC__Site__c>  AssocLocationLocList = [select name,id,BH_Location_Address__c,Superior_Asset_Count__c,
                                                      SVMXC__Account__c,SVMXC__Account__r.name,SVMXC__City__c,
                                                      SVMXC__State__c,SVMXC__Country__c,
                                                      (select id,name,BH_US_SM_Superior_Asset__c from R00N70000001hzcqEAA__r where BH_US_SM_Superior_Asset__c!=null),
                                                      SVMXC__Zip__c from SVMXC__Site__c where id in:Locid];
        system.debug('AssocLocationList common'+AssocLocationLocList);
        String AssetCount;
        for(SVMXC__Site__c acc : AssocLocationLocList){
            AssetCount  = String.valueOf(acc.R00N70000001hzcqEAA.size());
            }
            system.debug('Number of assets '+ AssetCount );
            AssocLocationLocList.sort();
            return AssocLocationLocList; 
            } 
         
}

Thanks,
Anil Kumar