Skip to main content

USING SCOPE

public inherited sharing class AccountSelector {

public static SOQL Query {
get {
return SOQL.of(Account.sObjectType)
.fields(new List<sObjectField>{
Account.Id,
Account.Name
});
}
}
}

public with sharing class MyController {

public static List<Account> getMineAccounts() {
return (List<Account>) AccountSelector.Query
.mineScope()
.asList();
}

public static List<Account> getTeamAccounts() {
return (List<Account>) AccountSelector.Query
.myTeamScope()
.asList();
}
}