As of Dec 22nd the fflib_Selector was updated to use the Apex Data Access modes in its constructor.
Below is an example of a selector class that is set to run in usermode by default via the constructor. We must also provide a value for the use of field sets.
public inherited sharing class AccountSelector extends fflib_SObjectSelector {
public AccountSelector(){
super(false, DataAccess.USER_MODE);
}
public SObjectType getSObjectType() {
//All selectors must implement
return Account.SObjectType;
}
public List<SObjectField> getSObjectFieldList() {
//All selectors must implement
return new List<SObjectField>{
Account.Id,
Account.Name,
Account.AccountNumber,
Account.Industry,
Account.Rating,
Account.NumberOfEmployees
};
}
}
If we want the selector to run in System mode, we configure that at the instance level.
AccountSelector accountSelector = new AccountSelector();
accountSelector.setDataAccess(fflib_SObjectSelector.DataAccess.SYSTEM_MODE);
An example query string would look like the following.
SELECT id, name, accountnumber,
industry, rating, numberofemployees, type, description
FROM Account
WITH SYSTEM_MODE
ORDER BY Name
ASC
NULLS FIRST
LIMIT 10