SELECT
Specify fields that will be retrieved via query. Check SOQLCache Cache API - SELECT.
NOTE! ๐จ All examples use inline queries built with the SOQL Lib Query Builder. If you are using a selector, replace
SOQLCache.of(...)withYourCachedSelectorName.query().
Fieldsโ
SObjectField fields (Recommended)โ
SOQL
Traditional SOQL
SELECT Id, Name, BillingCity
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with(Account.Id, Account.Name, Account.BillingCity)
.byId('1234')
.toObject();
More than 5 fields:
SOQL
Traditional SOQL
SELECT
Id,
Name,
Industry,
Rating,
AnnualRevenue,
BillingCity,
Phone
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with(new List<SObjectField> {
Account.Id,
Account.Name,
Account.Industry,
Account.Rating,
Account.AnnualRevenue,
Account.BillingCity,
Account.Phone
})
.byId('1234')
.toObject();
String fieldsโ
SOQL
Traditional SOQL
SELECT Id, Name, Industry, Rating, AnnualRevenue, BillingCity, Phone
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with('Id, Name, Industry, Rating, AnnualRevenue, BillingCity, Phone')
.byId('1234')
.toObject();
Relationship Fieldsโ
Single Relationship Fieldโ
SOQL
Traditional SOQL
SELECT Id, Name, Owner.Name
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with(Account.Id, Account.Name)
.with('Owner', User.Name)
.byId('1234')
.toObject();
Multiple Relationship Fieldsโ
SOQL
Traditional SOQL
SELECT Id, Name, Owner.Name, Owner.Email, CreatedBy.Name
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with(Account.Id, Account.Name)
.with('Owner', User.Name, User.Email)
.with('CreatedBy', User.Name)
.byId('1234')
.toObject();
Relationship Fields with Listโ
SOQL
Traditional SOQL
SELECT Id, Name, Owner.Name, Owner.Email, Owner.Profile.Name
FROM Account
WHERE Id = '1234'
SOQL Lib
SOQL Cache Approach
SOQLCache.of(Account.SObjectType)
.with(Account.Id, Account.Name)
.with('Owner', new List<SObjectField>{ User.Name, User.Email })
.with('Owner.Profile', Profile.Name)
.byId('1234')
.toObject();