@@ -9,7 +9,8 @@ For more details, please refer to the [documentation](https://soql-lib.vercel.ap
99
1010You may also find [ this blog post] ( https://beyondthecloud.dev/blog/soql-lib ) about SOQL Lib interesting.
1111
12- ## Examples
12+
13+ ** Standard SOQL**
1314
1415``` apex
1516// SELECT Id FROM Account
@@ -23,14 +24,20 @@ List<Account> accounts = SOQL.of(Account.SObjectType)
2324 .toList();
2425```
2526
26- ## Selector
27+ ** Cached SOQL**
28+
29+ ``` apex
30+ // SELECT Id, Name, UserType FROM Profile WHERE Name = 'System Administrator'
31+ Profile systemAdminProfile = (Profile) SOQLCache.of(Profile.SObjectType)
32+ .with(Profile.Id, Profile.Name, Profile.UserType)
33+ .whereEqual(Profile.Name, 'System Administrator')
34+ .toObject();
35+ ```
2736
28- Read [ how to build your selector class ] ( https://soql-lib.vercel.app/building-your-selector ) .
37+ ## Selector
2938
3039``` apex
3140public inherited sharing class SOQL_Contact extends SOQL implements SOQL.Selector {
32- public static final String MOCK_ID = 'SOQL_Contact';
33-
3441 public static SOQL_Contact query() {
3542 return new SOQL_Contact();
3643 }
@@ -40,8 +47,7 @@ public inherited sharing class SOQL_Contact extends SOQL implements SOQL.Selecto
4047 // default settings
4148 with(Contact.Id, Contact.Name, Contact.AccountId)
4249 .systemMode()
43- .withoutSharing()
44- .mockId(MOCK_ID);
50+ .withoutSharing();
4551 }
4652
4753 public SOQL_Contact byAccountId(Id accountId) {
@@ -64,6 +70,31 @@ public with sharing class ExampleController {
6470}
6571```
6672
73+ ## Cached Selector
74+
75+ ``` apex
76+ public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector {
77+ public static SOQL_ProfileCache query() {
78+ return new SOQL_ProfileCache();
79+ }
80+
81+ private SOQL_ProfileCache() {
82+ super(Profile.SObjectType);
83+ cacheInOrgCache();
84+ with(Profile.Id, Profile.Name, Profile.UserType);
85+ }
86+
87+ public override SOQL.Queryable initialQuery() {
88+ return SOQL.of(Profile.SObjectType);
89+ }
90+
91+ public SOQL_ProfileCache byName(String name) {
92+ whereEqual(Profile.Name, name);
93+ return this;
94+ }
95+ }
96+ ```
97+
6798## Deploy to Salesforce
6899
69100<a href =" https://githubsfdeploy.herokuapp.com?owner=beyond-the-cloud-dev&repo=soql-lib&ref=main " >
0 commit comments