-
-
Save arun12209/8c1c79f76d70091915b445f1c6eb7b89 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
public with sharing class LazyLoadingController { | |
@AuraEnabled(cacheable=true) | |
public static Map<String, Object> getContactRecords(Integer pageSize, Integer page) { | |
Integer offset = Math.max(0, (page - 1) * pageSize); | |
List<Contact> contacts = [SELECT Id, Name, Email, Phone FROM Contact ORDER BY Name ASC LIMIT :pageSize OFFSET :offset]; | |
Integer totalRecords = [SELECT COUNT() FROM Contact]; | |
Map<String, Object> result = new Map<String, Object>(); | |
result.put('contacts', contacts); | |
result.put('totalRecords', totalRecords); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment