### Start Local Development Server Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/README.md Starts a local development server that reflects changes live without requiring a restart. ```bash $ yarn start ``` -------------------------------- ### SOQL Query Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md A basic SOQL query example. ```sql SELECT Id FROM Account ``` -------------------------------- ### Install Dependencies Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/README.md Installs project dependencies using Yarn. ```bash $ yarn ``` -------------------------------- ### SOQL Lib Field Selection Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Demonstrates selecting fields using the `with` method. Fields can be chained or added individually. ```apex SOQL.of(Account.SObjectType) .with(Account.Id, Account.Name) .toList(); // or SOQL.of(Account.SObjectType) .with(Account.Id) .with(Account.Name) .toList(); ``` -------------------------------- ### Example Controller for MyTeam Account Queries Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/build-selector.md Provides methods to retrieve accounts using MyTeam_AccountSelector. Demonstrates using the overridden query and inherited methods. ```apex public with sharing class ExampleController { public static List getAccounts(String accountName) { return new MyTeam_AccountSelector().query() .with(Account.BillingCity, Account.BillingCountry) .whereAre(SOQL.Filter.name().contains(accountName)) .toList(); } public static List getAccountsByRecordType(String recordType) { return new MyTeam_AccountSelector().byRecordType(recordType) .with(Account.ParentId) .toList(); } } ``` -------------------------------- ### Example Controller for Account Contacts Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/README.md An example controller method to retrieve contacts for a given account, using the SOQL_Contact selector. This demonstrates how to integrate selectors into Apex classes. ```apex public with sharing class ExampleController { @AuraEnabled public static List getAccountContacts(Id accountId) { return SOQL_Contact.query() .byRecordType('Partner') .byAccountId(accountId) .with(Contact.Email) .toList(); } } ``` -------------------------------- ### Example Controller for Account Query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/fls.md This controller class demonstrates calling the SOQL_Account selector to retrieve accounts. It relies on the selector's default security settings. ```apex public without sharing class ExampleController { public static List getAccountsByRecordType(String recordType) { return SOQL_Account.query().toList(); } } ``` -------------------------------- ### Example Controller for Account Queries Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/build-selector.md Provides AuraEnabled methods to retrieve accounts using the SOQL_Account selector. Demonstrates chaining non-static query methods. ```apex public with sharing class ExampleController { @AuraEnabled public static List getPartnerAccounts(String accountName) { return new SOQL_Account() .with(Account.BillingCity, Account.BillingCountry) .whereAre(SOQL.FilterGroup .add(SOQL.Filter.name().contains(accountName)) .add(SOQL.Filter.recordType().equal('Partner')) ) .toList(); } @AuraEnabled public static List getAccountsByRecordType(String recordType) { return new SOQL_Account() .byRecordType(recordType) .byIndustry('IT') .with(Account.Industry, Account.AccountSource) .toList(); } @AuraEnabled public static String getAccountIndustry(Id accountId) { return new SOQL_Account().toIndustry(accountId); } } ``` -------------------------------- ### SOQL Query Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-filters-group.md This is a standard SOQL query demonstrating filtering conditions. ```sql SELECT Id FROM Account WHERE Industry = 'IT' AND Name LIKE '%MyAccount%' ``` -------------------------------- ### Example Controller for Cached Profile Query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/basic-features.md Demonstrates how to retrieve a profile using the SOQL cache. The first call populates the cache, while subsequent calls retrieve from it. ```apex public with sharing class ExampleController { @AuraEnabled public static Id getSystemAdminProfileId() { // First call: executes initial query and caches all profiles Profile adminProfile = (Profile) SOQL_CachedProfile.query() .byName('System Administrator') .toId(); // Subsequent call: retrieves from cache, no database query return SOQL_CachedProfile.query() .byName('Standard User') .toId(); } } ``` -------------------------------- ### Initialize SubQuery Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-sub.md Demonstrates the initialization of a SubQuery for a specified object type. This is the starting point for building any subquery. ```sql SELECT Id, ( SELECT Id FROM Contacts ) FROM Account ``` ```apex SOQL.of(Account.SObjectType) .with(SOQL.SubQuery.of('Contacts')) .toList(); ``` -------------------------------- ### SOQL Query Example (Incorrect) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/design.md This example shows a query without any filter conditions, which cannot guarantee cache consistency with the database. ```soql SELECT Id, Name FROM Profile ``` -------------------------------- ### Cached Profile Records Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/design.md An example of how profile records are stored in the cache, including metadata like `cachedDate` and the `record` itself. ```json [ { cachedDate=2025-01-10 12:23:51, id=00e3V000000Nme3QAC, record=Profile:{ Id=00e3V000000Nme3QAC, Name=System Administrator, UserType=Standard } }, { cachedDate=2025-01-10 12:23:51, id=00e3V000000DhteQAC, record=Profile:{ Id=00e3V000000DhteQAC, Name=Standard Guest, UserType=Guest } } // ... ] ``` -------------------------------- ### Example Controller for Contact Queries Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/build-selector.md Provides AuraEnabled methods to retrieve contacts using the SOQL_Contact selector. Demonstrates calling static query methods. ```apex public with sharing class ExampleController { @AuraEnabled public static List getContactsByRecordType(String recordType) { return SOQL_Contact.byRecordType(recordType) .with(Contact.Email, Contact.Title) .toList(); } @AuraEnabled public static List getContactsRelatedToAccount(Id accountId) { return SOQL_Contact.byAccountId(accountId).toList(); } @AuraEnabled public static String getContactName(Id contactId) { return SOQL_Contact.toName(contactId); } } ``` -------------------------------- ### SOQL Inner Join Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-join.md This SQL example demonstrates a subquery in the WHERE clause, selecting `AccountId` from `Contact` where the `Name` is 'My Contact'. ```sql SELECT Id FROM Account WHERE Id IN ( SELECT AccountId FROM Contact WHERE Name = 'My Contact' ) ``` -------------------------------- ### Setup Sequential Mocks for a Query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/mocking.md Demonstrates how to set up multiple sequential mocks for the same query identifier using `SOQL.mock(mockId).thenReturn(data)`. Mocks are consumed in FIFO order. ```apex // Setup multiple sequential mocks SOQL.mock('testQuery').thenReturn(new Account(Name = 'First Call')); SOQL.mock('testQuery').thenReturn(new Account(Name = 'Second Call')); SOQL.mock('testQuery').thenReturn(new Account(Name = 'Third Call')); // First execution returns "First Call", then removes that mock Account result1 = SOQL.of(Account.SObjectType).mockId('testQuery').toObject(); // Second execution returns "Second Call", then removes that mock Account result2 = SOQL.of(Account.SObjectType).mockId('testQuery').toObject(); // Third execution returns "Third Call", but do not removes that mock - it's the last mock on the stack Account result3 = SOQL.of(Account.SObjectType).mockId('testQuery').toObject(); // Fourth execution returns "Third Call" - it's the last mock on the stack Account result4 = SOQL.of(Account.SObjectType).mockId('testQuery').toObject(); ``` -------------------------------- ### SOQL Query Example (Correct) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/design.md This example demonstrates a query that correctly filters by a unique field ('Id') to ensure cache consistency and enable single-object retrieval. ```soql SELECT Id, Name, UserType FROM Profile WHERE Id = '00e3V000000Nme3QAC' ``` -------------------------------- ### SOQLEvaluator Constructor Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/evaluator/api/soql-evaluator.md Constructs a SOQLEvaluator instance from a list of SObject records. This is useful for processing pre-fetched data. ```apex SOQLEvaluator.of([ SELECT Id, Name, Industry FROM Account WITH USER_MODE ]).toList(); ``` -------------------------------- ### Example Controller - Partner Accounts Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/build-selector.md This controller method demonstrates building a SOQL query inline using the SOQL_Account selector. It specifies fields, filters by record type and account name, and retrieves a list of accounts. ```apex public with sharing class ExampleController { @AuraEnabled public static List getPartnerAccounts(String accountName) { return SOQL_Account.query() .byRecordType('Partner') .whereAre(SOQL.Filter.name().contains(accountName)) .with(Account.BillingCity, Account.BillingCountry) .toList(); } @AuraEnabled public static List getAccountsByRecordType(String recordType) { return SOQL_Account.query() .byIndustry('IT') .byRecordType(recordType) .with(Account.Industry, Account.AccountSource) .toList(); } } ``` -------------------------------- ### SOQL Inner Join Example (No Filter) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-join.md This SQL example demonstrates a basic inner join in a subquery, selecting `AccountId` from `Contact` without any additional filters. ```sql SELECT Id FROM Account WHERE Id IN ( SELECT AccountId FROM Contact ) ``` -------------------------------- ### Debug Log Output for Query Preview Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Example of the debug log output when using the query preview feature, showing the generated SOQL query and its bindings. ```text ============ Query Preview ============ SELECT Id, Name, UserType FROM Profile WHERE Name = :v1 ======================================= ============ Query Binding ============ { "v1" : "System Administrator" } ======================================= ``` -------------------------------- ### Dynamic SOQL Query with String Concatenation (Example of what to avoid) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/basic-features.md This is an example of how dynamic SOQL queries can be built using string concatenation, which is prone to errors and harder to maintain. It is provided for comparison with the SOQL.cls approach. ```apex String accountName = ''; String query = 'SELECT Id, Name WHERE BillingCity = \'Krakow\'"; if (String.isNotEmpty(accountName)) { query += ' AND Name LIKE \'%' + accountName +'\'%'; } query += ' FROM Account'; Database.query(query); ``` -------------------------------- ### startsWith Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Filters results where a field starts with a specific string, using LIKE. ```APIDOC ## startsWith ### Description Filters results where a field starts with a specific string. ### Method `startsWith(String value)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT SUM(AnnualRevenue) FROM Lead GROUP BY City HAVING City LIKE 'San%' ``` ### Response #### Success Response (200) None (This is a filter method, not an endpoint) #### Response Example None ``` -------------------------------- ### SOQL HavingFilter Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Demonstrates how to use HavingFilter to specify a sum condition for aggregated results. ```apex SOQL.of(Lead.SObjectType) .sum(Lead.AnnualRevenue) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.sum(Lead.AnnualRevenue).greaterThan(1000000)) .toAggregated(); ``` -------------------------------- ### SOQL Lib LIMIT Clause Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/limit.md Demonstrates how to set a limit for SOQL queries using the SOQL Lib Query Builder. Ensure you replace SOQL.of(...) with YourSelectorName.query() if using a selector. ```apex SOQL.of(Account.SObjectType) .setLimit(100) .toList(); ``` -------------------------------- ### SOQL Lib Related Fields Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Demonstrates selecting fields from a related object using the `with` method. The relationship name is provided as the first argument. ```apex SOQL.of(Account.SObjectType) .with('CreatedBy', User.Name) .toList(); SOQL.of(Account.SObjectType) .with('CreatedBy', User.Id, User.Name, User.Phone) .toList(); ``` -------------------------------- ### With Sharing Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/basic-features.md Executes a SOQL query in system mode but enforces sharing rules using `.withSharing()`. This respects record sharing rules while potentially bypassing FLS if `.systemMode()` is also used. ```apex // Query executed with sharing (respects sharing rules) SOQL.of(Account.SObjectType) .with(Account.Id, Account.Name) .systemMode() .withSharing() .toList(); ``` -------------------------------- ### SOQLCache Mocking for a Specific Method Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/mocking.md Example of mocking a specific controller method using SOQLCache. This is useful for isolating and testing individual controller functionalities. ```apex @IsTest private class ExampleControllerTest { @IsTest static void getPartnerAccount() { SOQLCache.mock('ExampleController.getPartnerAccount').thenReturn(new Account(Name = 'MyAccount 1')); // Test Account result = ExampleController.getPartnerAccount('MyAccount'); Assert.areEqual('MyAccount 1', result.Name); } } ``` -------------------------------- ### Cached Selector Usage Examples Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/basic-features.md Demonstrates various ways to use the `SOQL_CachedProfile` cached selector to retrieve profile data, check for existence, get an ID, or extract specific field values. ```apex // Get single profile Profile adminProfile = (Profile) SOQL_CachedProfile.query() .byName('System Administrator') .toObject(); // Check if profile with give criteria exists Boolean profileExists = SOQL_CachedProfile.query() .byName('Standard User') .doExist(); // Get profile ID from profile Id profileId = SOQL_CachedProfile.query() .byName('System Administrator') .toId(); // Extract specific field value from profile String userType = (String) SOQL_CachedProfile.query() .byName('System Administrator') .toValueOf(Profile.UserType); ``` -------------------------------- ### Dynamic SOQL Query with SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/basic-features.md Use SOQL.cls to build dynamic SOQL queries programmatically, which is more readable and maintainable than string concatenation. This example filters accounts by city and name. ```apex String accountName = ''; SOQL.of(Account.SObjectType) .with(Account.Id, Account.Name) .whereAre(SOQL.FilterGroup .add(SOQL.Filter.with(Account.BillingCity).equal('Krakow')) .add(SOQL.Filter.name().contains(accountName).ignoreWhen(String.isEmpty(accountName))) ) .toList(); ``` -------------------------------- ### Org Cache Implementation Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Example of a custom selector class that utilizes SOQLCache with Org cache. This strategy is suitable for data that can be shared across multiple transactions and users. ```apex public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector { public static SOQL_ProfileCache query() { return new SOQL_ProfileCache(); } private SOQL_ProfileCache() { super(Profile.SObjectType); cacheInOrgCache(); // <=== Cache in Org Cache } public override SOQL.Queryable initialQuery() { return SOQL.of(Profile.SObjectType).systemMode().withoutSharing(); } } ``` -------------------------------- ### Mocking a List of Records in SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/mocking.md Example of mocking a list of records for a specific controller method. This is useful for testing scenarios that involve multiple records returned by a SOQL query. ```apex @IsTest private class ExampleControllerTest { @IsTest static void getPartnerAccounts() { List accounts = new List{ new Account(Name = 'MyAccount 1'), new Account(Name = 'MyAccount 2') }; SOQL.mock('ExampleController.getPartnerAccounts').thenReturn(accounts); // Test List result = ExampleController.getPartnerAccounts('MyAccount'); Assert.areEqual(accounts, result); } } ``` -------------------------------- ### SOQL Selector Usage Examples Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/basic-features.md Demonstrates various ways to use the SOQL_Account selector, including basic usage with default configurations, chaining methods for specific filters, and extending queries with additional fields and clauses dynamically. ```apex // Basic usage with default configuration // SELECT Id, NAME FROM Account WITH SYSTEM_MODE List allAccounts = SOQL_Account.query().toList(); ``` ```apex // Chain selector methods /* SELECT Id, Name, AnnualRevenue FROM Account WHERE Type = 'Partner' AND Industry = 'Technology' WITH SYSTEM_MODE */ List techPartners = SOQL_Account.query() .byType('Partner') .byIndustry('Technology') .with(Account.AnnualRevenue) // pull additional fields .toList(); ``` ```apex // Extend with additional fields and clauses dynamically /* SELECT Id, Name, AnnualRevenue, BillingCity FROM Account WHERE Industry = 'Technology' AND AnnualRevenue > 1000000 ORDER BY AnnualRevenue DESC WITH SYSTEM_MODE LIMIT 10 */ List topAccounts = SOQL_Account.query() .byIndustry('Technology') .whereAre(SOQL.Filter.with(Account.AnnualRevenue).greaterThan(1000000)) .with(Account.AnnualRevenue, Account.BillingCity) .orderBy(Account.AnnualRevenue).sortDesc() .setLimit(10) .toList(); ``` -------------------------------- ### Mock SOQL Results for Unit Tests in Apex Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/src/pages/soqlLibBenefits.mdx Boost unit test performance by mocking SOQL results, reducing the need for complex test data setups. ```apex List accounts = new List{ new Account(Name = 'MyAccount 1'), new Account(Name = 'MyAccount 2') }; SOQL.mock('ExampleController.getPartnerAccounts') .thenReturn(accounts); Test.startTest(); List result = ExampleController.getPartnerAccounts('MyAccount'); Test.stopTest(); // Assert ``` -------------------------------- ### Set Up and Use Mock Stack Functionality Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/mocking.md Demonstrates how to set up multiple sequential mocks for a single query identifier and how they are consumed during execution. Mocks are consumed in FIFO order, with the last mock on the stack being reused for subsequent calls. ```apex // Setup multiple sequential mocks SOQLCache.mock('testQuery').thenReturn(new Account(Name = 'First Call')); SOQLCache.mock('testQuery').thenReturn(new Account(Name = 'Second Call')); SOQLCache.mock('testQuery').thenReturn(new Account(Name = 'Third Call')); // First execution returns "First Call", then removes that mock Account result1 = (Account) SOQLCache.of(Account.SObjectType) .with(Account.Name) .whereEqual(Account.Name, 'Test') .mockId('testQuery') .toObject(); // Second execution returns "Second Call", then removes that mock Account result2 = (Account) SOQLCache.of(Account.SObjectType) .with(Account.Name) .whereEqual(Account.Name, 'Test') .mockId('testQuery') .toObject(); // Third execution returns "Third Call", but does not remove that mock - it's the last mock on the stack Account result3 = (Account) SOQLCache.of(Account.SObjectType) .with(Account.Name) .whereEqual(Account.Name, 'Test') .mockId('testQuery') .toObject(); // Fourth execution returns "Third Call" - it's the last mock on the stack Account result4 = (Account) SOQLCache.of(Account.SObjectType) .with(Account.Name) .whereEqual(Account.Name, 'Test') .mockId('testQuery') .toObject(); ``` -------------------------------- ### SOQL Query Example (Incorrect) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/design.md This example demonstrates a query that may lead to inconsistent cached results because it filters by a non-unique field ('UserType'). ```soql SELECT Id, Name FROM Profile WHERE UserType = 'Standard' ``` -------------------------------- ### Example of a non-cached SOQL query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/advanced/design.md This example demonstrates a typical SOQL query that does not utilize caching and includes methods not applicable to cached records. ```apex SOQL.of(Profile.SObjectType) .with(Profile.Id, Profile.Name, Profile.UserType) .myTerritoryScope() .forView() .withSharing() .toList(); ``` -------------------------------- ### Initialize SOQL Query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Use this method to set up the initial SOQL query with system mode and without sharing. It's part of the SOQLCache implementation for Profile objects. ```apex public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector { public static SOQL_ProfileCache query() { return new SOQL_ProfileCache(); } private SOQL_ProfileCache() { super(Profile.SObjectType); cacheInOrgCache(); with(Profile.Id, Profile.Name, Profile.UserType) } public override SOQL.Queryable initialQuery() { // <=== Initial query return SOQL.of(Profile.SObjectType).systemMode().withoutSharing(); } } ``` -------------------------------- ### SOQL LIMIT Clause Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/limit.md Use the LIMIT clause to restrict the number of records returned by a SOQL query. This example shows the traditional SOQL syntax. ```sql SELECT Id FROM Account LIMIT 100 ``` -------------------------------- ### SOQL Query Initialization Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Demonstrates how to initialize a SOQL query using the `initialQuery` method. ```APIDOC ## initialQuery ### Description Initializes a SOQL query with default settings. ### Method `SOQL.Queryable initialQuery()` ### Example ```apex public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector { public static SOQL_ProfileCache query() { return new SOQL_ProfileCache(); } private SOQL_ProfileCache() { super(Profile.SObjectType); cacheInOrgCache(); with(Profile.Id, Profile.Name, Profile.UserType) } public override SOQL.Queryable initialQuery() { // <=== Initial query return SOQL.of(Profile.SObjectType).systemMode().withoutSharing(); } } ``` ``` -------------------------------- ### SOQL Lib Query with System Mode and Sharing Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/sharing-settings.md Use SOQL Lib's `.systemMode()` and `.withSharing()` to execute queries with system permissions, respecting sharing rules. ```apex SOQL.of(Account.SObjectType) .systemMode() .withSharing() .toList(); ``` -------------------------------- ### Basic SOQL Query Construction Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Demonstrates the basic usage of the SOQL library to construct a simple query. ```apex SOQL.of(Account.SObjectType) .with(Account.Id, Account.Name) .toList(); ``` -------------------------------- ### Deploy Website (SSH) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/README.md Deploys the website using SSH. Assumes SSH is configured for deployment. ```bash $ USE_SSH=true yarn deploy ``` -------------------------------- ### notStartsWith Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Filters results where a field does not start with a specific string, using NOT LIKE. ```APIDOC ## notStartsWith ### Description Filters results where a field does not start with a specific string. ### Method `notStartsWith(String value)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT SUM(AnnualRevenue) FROM Lead GROUP BY City HAVING (NOT City LIKE 'San%') ``` ### Response #### Success Response (200) None (This is a filter method, not an endpoint) #### Response Example None ``` -------------------------------- ### Build Static Website Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/README.md Generates static content for the website into the 'build' directory, ready for hosting. ```bash $ yarn build ``` -------------------------------- ### Mocking Data from Static Resource in SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/mocking.md Shows how to mock data for a controller method using a static resource. This is helpful for testing with predefined datasets. ```apex @IsTest private class ExampleControllerTest { @IsTest static void getPartnerAccounts() { SOQL.mock('ExampleController.getPartnerAccounts').thenReturn(Test.loadData(Account.SObjectType, 'ProjectAccounts')); // Test List result = ExampleController.getPartnerAccounts('MyAccount'); Assert.areEqual(5, result.size()); } } ``` -------------------------------- ### toInteger - Get Count as Integer Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Converts the query result count into an Integer. ```APIDOC ## toInteger() ### Description Converts the query result count into an Integer. ### Method SOQL ### Endpoint N/A (Method within SOQL builder) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```apex SOQL.of(Account.SObjectType).count().toInteger(); ``` ### Response #### Success Response (200) - **Integer** - The count of records as an integer. #### Response Example ```apex Integer // Example: 100 ``` ``` -------------------------------- ### Result Set Manipulation Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Methods for controlling the number of records returned and their starting point. ```APIDOC ## LIMIT Clause ### setLimit ### Description Applies a LIMIT clause to the SOQL query, specifying the maximum number of rows to return. ### Method `Queryable setLimit(Integer amount)` ### Parameters #### Query Parameters - **amount** (Integer) - Required - The maximum number of rows to return. ### Request Example ```apex SOQL.of(Account.SObjectType) .setLimit(100) .toList(); ``` ### Response Example (Implicitly affects the SOQL query generated) ``` ```APIDOC ## OFFSET Clause ### offset ### Description Applies an OFFSET clause to the SOQL query, specifying the number of rows to skip from the beginning of the result set. ### Method `Queryable offset(Integer startingRow)` ### Parameters #### Query Parameters - **startingRow** (Integer) - Required - The number of rows to skip. ### Request Example ```apex SOQL.of(Account.SObjectType) .setOffset(10) .toList(); ``` ### Response Example (Implicitly affects the SOQL query generated) ``` -------------------------------- ### HavingFilter isNull Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Demonstrates using isNull() with a HavingFilter to check for null values in a specified field. ```sql SELECT COUNT(Name) FROM Lead GROUP BY LeadSource HAVING LeadSource = NULL ``` ```apex SOQL.of(Lead.SObjectType) .count(Lead.Name) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.with(Lead.LeadSource).isNull()) .toAggregated(); ``` -------------------------------- ### HavingFilter Sum Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Applies a sum aggregation to the 'AnnualRevenue' field within a HavingFilter, with a greaterThan condition. ```sql SELECT LeadSource FROM Lead GROUP BY LeadSource HAVING SUM(AnnualRevenue) > 1000000 ``` ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.sum(Lead.AnnualRevenue).greaterThan(1000000)) .toAggregated(); ``` -------------------------------- ### HavingFilter Max Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Applies a max aggregation to the 'NumberOfEmployees' field within a HavingFilter, with a lessThan condition. ```sql SELECT LeadSource FROM Lead GROUP BY LeadSource HAVING MAX(NumberOfEmployees) < 100 ``` ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.max(Lead.NumberOfEmployees).lessThan(100)) .toAggregated(); ``` -------------------------------- ### SOQL Initialization Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Constructs an SOQL query builder instance. ```APIDOC ## INIT ### of Constructs an `SOQL` query builder. **Signature** ```apex title="Method Signatures" Queryable of(SObjectType ofObject) Queryable of(String ofObject) ``` **Example** ```sql title="SOQL Query" SELECT Id FROM Account ``` ```apex title="SOQL Lib Implementation" SOQL.of(Account.SObjectType).toList(); SOQL.of('Account').toList(); ``` ``` -------------------------------- ### HavingFilter Min Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Applies a min aggregation to the 'NumberOfEmployees' field within a HavingFilter, with a greaterThan condition. ```sql SELECT LeadSource FROM Lead GROUP BY LeadSource HAVING MIN(NumberOfEmployees) > 100 ``` ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.min(Lead.NumberOfEmployees).greaterThan(100)) .toAggregated(); ``` -------------------------------- ### HavingFilter CountDistinct Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Applies a countDistinct aggregation to the 'Name' field within a HavingFilter, with a greaterThan condition. ```sql SELECT LeadSource FROM Lead GROUP BY LeadSource HAVING COUNT_DISTINCT(Name) > 100 ``` ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.countDistinct(Lead.Name).greaterThan(100)) .toAggregated(); ``` -------------------------------- ### Clone SOQL Lib Repository Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/CONTRIBUTING.md Clone your forked repository to your local machine and navigate into the project directory. ```bash git clone https://github.com/YOUR_USERNAME/soql-lib.git cd soql-lib ``` -------------------------------- ### HavingFilter Count Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-having-filter.md Applies a count aggregation to the 'Name' field within a HavingFilter, with a greaterThan condition. ```sql SELECT LeadSource FROM Lead GROUP BY LeadSource HAVING COUNT(Name) > 100 ``` ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .have(SOQL.HavingFilter.count(Lead.Name).greaterThan(100)) .toAggregated(); ``` -------------------------------- ### Preview SOQL Query with SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/debug.md Use the `.preview()` method to generate and view the SOQL query string. This is useful for debugging and understanding the generated query before execution. Ensure you are using SOQL Lib's Query Builder syntax. ```apex SOQL.of(Account.SObjectType) .with( Account.Id, Account.Name, Account.BillingCity, Account.BillingCountry, Account.BillingCountryCode ) .whereAre(SOQL.FilterGroup .add(SOQL.Filter.id().equal('0013V00000WNCw4QAH')) .add(SOQL.Filter.name().contains('Test')) .anyConditionMatching() ) .preview() .toList(); ``` -------------------------------- ### Generate Query Locator using SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/result.md Use SOQL Lib's toQueryLocator to create a Database.QueryLocator object. This is a more concise alternative to the traditional method. ```apex Database.QueryLocator queryLocator = Database.getQueryLocator('SELECT Id FROM ACCOUNT'); ``` ```apex Database.QueryLocator queryLocator = SOQL.of(Account.SObjectType) .with(Account.Id, Account.Name) .toQueryLocator(); ``` -------------------------------- ### SOQL Evaluator Initialization Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/evaluator/api/soql-evaluator.md Initialize the SOQL Evaluator with a list of SObject records. This is the starting point for most operations. ```APIDOC ## POST /api/users ### Description Initializes the SOQL Evaluator with a list of SObject records. ### Method POST ### Endpoint /api/users ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **staticQueryRecords** (List) - Required - The list of SObject records to initialize the evaluator with. ### Request Example ```json { "staticQueryRecords": [ { "Id": "001xxxxxxxxxxxx", "Name": "Test Account", "Industry": "Technology" } ] } ``` ### Response #### Success Response (200) - **evaluable** (SObjectEvaluable) - The initialized SOQL evaluator instance. #### Response Example ```json { "evaluable": "..." } ``` ``` -------------------------------- ### JoinQuery Construction and Usage Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-join.md Demonstrates how to construct a join query using the JoinQuery class and its methods. ```APIDOC ## POST /api/joinquery ### Description Constructs a join-query and uses it in a condition. ### Method POST ### Endpoint /api/joinquery ### Request Body - **object** (object) - Required - The JoinQuery object to construct. ### Request Example ```json { "query": "SOQL.of(Account.SObjectType).whereAre(SOQL.Filter.with(Account.Id).isIn(SOQL.InnerJoin.of(Contact.SObjectType).with(Contact.AccountId)))" } ``` ### Response #### Success Response (200) - **result** (string) - The constructed SOQL query string. #### Response Example ```json { "result": "SELECT Id FROM Account WHERE Id IN (SELECT AccountId FROM Contact)" } ``` ``` -------------------------------- ### Retrieve List of Records with SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/result.md Demonstrates fetching a list of records with specified fields using SOQL Lib. `toList()` is used to return the results as a List. ```apex Account account = [SELECT Id, Name FROM Account]; ``` ```apex List accounts = SOQL.of(Account.SObjectType).with(Account.Id, Account.Name).toList(); ``` -------------------------------- ### MAX aggregation on a related field Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Gets the maximum value of a field from a related object. The relationship name is required. ```sql SELECT MAX(Campaign.BudgetedCost) FROM CampaignMember ``` ```apex SOQL.of(CampaignMember.SObjectType) .max('Campaign', Campaign.BudgetedCost) .toAggregate(); ``` -------------------------------- ### Create Map with Custom Key (Account Name) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/result.md Compares traditional Apex map creation with SOQL library's `toMap` for mapping Account names to Account records. Use SOQL lib for concise code. ```apex Map nameToAccount = new Map(); for (Account acc : [SELECT Id, Name FROM Account]) { nameToAccount.put(acc.Name, acc); } ``` ```apex Map nameToAccount = (Map) SOQL.of(Account.SObjectType) .toMap(Account.Name); ``` -------------------------------- ### toAggregated - Get Aggregated Results Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql.md Retrieves the query results as a List of AggregateResult objects, typically used after GROUP BY clauses. ```APIDOC ## toAggregated() ### Description Retrieves the query results as a List of AggregateResult objects. This is typically used after applying aggregation functions and GROUP BY clauses. ### Method SOQL ### Endpoint N/A (Method within SOQL builder) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```apex SOQL.of(Lead.SObjectType) .with(Lead.LeadSource) .groupBy(Lead.LeadSource) .toAggregated() ``` ### Response #### Success Response (200) - **List** - A list of AggregateResult objects. #### Response Example ```apex List // Example: [AggregateResult1, AggregateResult2, ...] ``` ``` -------------------------------- ### Create Map with Custom Key and Value (Account Name to Industry) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/result.md Shows how to create a map where both the key (Account Name) and value (Industry) are custom fields, using traditional Apex and the SOQL library's `toMap`. ```apex Map accountNameToIndustry = new Map(); for (Account acc : [SELECT Id, Name, Industry FROM Account]) { accountNameToIndustry.put(acc.Name, acc.Industry); } ``` ```apex Map accountNameToIndustry = SOQL.of(Account.SObjectType) .toMap(Account.Name, Account.Industry); ``` -------------------------------- ### Mock Parent Relationship Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/mocking.md Mock a parent relationship by creating a nested SObject instance. This example mocks an Account with a parent Account. ```apex ```apex @IsTest private class ExampleControllerTest { @IsTest static void getPartnerAccountsCount() { SOQL.mock('mockingQuery').thenReturn( new Account( Name = 'Test', Parent = new Account(Name = 'Parent Name') ) ); Account result = (Account) ExampleController.getPartnerAccounts('MyAccount'); Assert.areEqual(2, result); } } ``` ``` -------------------------------- ### Executing Custom Account SOQL Queries Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/design.md Shows how to use the custom SOQL_Account selector to build and execute queries, including filtering by industry and ordering results. ```apex SOQL_Account.query() .byIndustry('IT') .orderBy(Account.Name) .toList(); ``` -------------------------------- ### Filter Account by Null Industry Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-filter.md This example shows how to filter Account records where the Industry field is NULL. The `isNull()` comparator is used. ```sql SELECT Id FROM Account WHERE Account.Industry = NULL ``` ```apex SOQL.of(Account.SObjectType) .whereAre(SOQL.Filter.with(Account.Industry).isNull()) .toList(); ``` -------------------------------- ### Strip Inaccessible Fields Example Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/evaluator/api/soql-evaluator.md Removes fields from queried records that the current user does not have access to. Can specify AccessType.READABLE for read-only access. ```apex List accessibleAccounts = SOQLEvaluator.of([ SELECT Id, Name, Industry FROM Account WITH USER_MODE ]).stripInaccessible().toList(); // or with specific access type List readableAccounts = SOQLEvaluator.of([ SELECT Id, Name, Industry FROM Account WITH USER_MODE ]).stripInaccessible(AccessType.READABLE).toList(); ``` -------------------------------- ### Select SObjectField Fields (SOQL Lib) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/select.md Use SOQL Lib to select specific SObjectField fields. This approach is recommended for type safety and clarity. Ensure SOQL Lib is initialized. ```sql SELECT Id, Name, BillingCity FROM Account ``` ```apex SOQL.of(Account.SObject) .with(Account.Id, Account.Name, Account.BillingCity) .toList(); ``` -------------------------------- ### Aggregate Account Names with SOQL Lib Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/src/pages/critique.md This snippet demonstrates the SOQL Lib approach to aggregating a list of account names, which is approximately 2x faster than manual iteration due to internal optimizations. ```apex Set accountNames = new Set(); for (Account acc : [SELECT Name FROM Account]) { accountNames.add(acc.Name); } ``` ```apex Set accountNames = SOQL.of(Account.SObjectType).toValuesOf(Account.Name); ``` -------------------------------- ### Implement Initial Query for Bulk Population Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md The `initialQuery()` method is used to populate the cache in bulk when it is empty. Subsequent queries will then use these cached records, improving performance. ```apex public with sharing class SOQL_ProfileCache extends SOQLCache implements SOQLCache.Selector { public static SOQL_ProfileCache query() { return new SOQL_ProfileCache(); } private SOQL_ProfileCache() { super(Profile.SObjectType); cacheInOrgCache(); with(Profile.Id, Profile.Name, Profile.UserType) } public override SOQL.Queryable initialQuery() { // <=== Initial query return SOQL.of(Profile.SObjectType).systemMode().withoutSharing(); } public SOQL_ProfileCache byName(String name) { whereEqual(Profile.Name, name); return this; } } ``` -------------------------------- ### Stage and Commit Changes Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/CONTRIBUTING.md Stage all your changes and commit them with a clear and concise message. Use conventional commit format if applicable. ```bash git add . git commit -m "feat: add support for XYZ feature" ``` -------------------------------- ### Nested SOQL Subquery Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/subquery.md Construct a nested subquery to query up to five levels of parent-to-child relationships. This example queries Assets related to Contacts, which are related to Accounts. ```sql SELECT Id, Name, ( SELECT FirstName, LastName , ( SELECT Id, AssetLevel FROM Assets ) FROM Contacts ) FROM Account ``` ```apex SOQL_Account.query() .with(Account.Id, Account.Name) .with(SOQL.SubQuery.of('Contacts') .with(Contact.FirstName, Contact.LastName) .with(SOQL.SubQuery.of('Assets') .with(Asset.Id, Asset.AssetLevel) ) ).toList(); ``` -------------------------------- ### SubQuery Construction Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-sub.md Demonstrates the basic construction of a subquery using the SOQL library. ```APIDOC ## POST /api/soql/subquery ### Description Constructs a SOQL subquery. ### Method POST ### Endpoint /api/soql/subquery ### Request Body - **objectType** (string) - Required - The object type for the subquery (e.g., 'Contacts'). - **fields** (array) - Optional - A list of fields to select within the subquery. - **subQueries** (array) - Optional - A list of nested subqueries. ### Request Example ```json { "objectType": "Contacts", "fields": ["Id", "Name", "Phone"] } ``` ### Response #### Success Response (200) - **subQuery** (object) - The constructed subquery object. #### Response Example ```json { "subQuery": { "objectType": "Contacts", "fields": ["Id", "Name", "Phone"] } } ``` ``` -------------------------------- ### SOQL Cache Basic Usage Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Demonstrates the basic usage of the SOQLCache class to query and cache Profile records. ```APIDOC ## SOQL Cache Basic Usage ### Description This example shows how to initialize and use the SOQLCache to query Profile records, filter them, and retrieve the result as an object. ### Method N/A (This is a usage example, not a specific API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```apex SOQLCache.of(Profile.SObjectType) .with(Profile.Id, Profile.Name, Profile.UserType) .whereEqual(Profile.Name, 'System Administrator') .toObject(); ``` ### Response #### Success Response (200) N/A (This is an Apex code example, not an HTTP response) #### Response Example N/A ``` -------------------------------- ### Select Multiple Relationship Fields Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Selects multiple fields from a related object. This example selects `Name` and `Email` from the `User` object via the `Owner` relationship. ```apex SOQLCache.of(Account.SObjectType) .with(Account.Id, Account.Name) .with('Owner', User.Name, User.Email) .whereEqual(Account.Id, '001000000000000AAA') .toObject(); ``` ```apex SOQLCache.of(Account.SObjectType) .with(Account.Id, Account.Name) .with('CreatedBy', User.Id, User.Name, User.Email) .whereEqual(Account.Id, '001000000000000AAA') .toObject(); ``` -------------------------------- ### Deploy Website (No SSH) Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/README.md Deploys the website without using SSH. Requires specifying the GitHub username. ```bash $ GIT_USER= yarn deploy ``` -------------------------------- ### SOQL Lib Query with SYSTEM_MODE, withoutSharing, and stripInaccessible Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/examples/fls.md Combine SYSTEM_MODE, withoutSharing, and stripInaccessible to enforce object and field-level security while ignoring sharing rules. ```apex SOQL.of(Account.SObjectType) .systemMode() .withoutSharing() .stripInaccessible() .toList(); ``` -------------------------------- ### Selector Interface Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/advanced/design.md The main entry point for creating SOQL queries. ```APIDOC ## Selector Interface ### Description The main interface to start building SOQL queries. ### Method - `query()`: Returns a `Queryable` object to begin constructing the query. ``` -------------------------------- ### Preview SOQL Query Execution Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Preview the SOQL query and its bindings that will be executed. The output is available in the debug logs. ```apex SOQLCache.of(Profile.SObjectType) .with(Profile.Id, Profile.Name, Profile.UserType) .whereEqual('Name', 'System Administrator') .preview() .toObject(); ``` -------------------------------- ### Construct a Basic Join Query Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/soql/api/soql-join.md Use `SOQL.of()` to start building a query and `whereAre()` with `SOQL.InnerJoin.of()` to specify the join condition. This is useful for querying related records. ```apex SOQL.of(Account.SObjectType) .whereAre(SOQL.Filter.with(Account.Id).isIn( SOQL.InnerJoin.of(Contact.SObjectType) .with(Contact.AccountId) )).toList(); ``` -------------------------------- ### Get Related Field ID with SOQLCache Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/basic-features.md Extract the ID of a related field from a cached record using the `toIdOf()` method, specifying the field API name. ```apex public static Id getProfileUserLicenseId(String profileName) { return SOQL_CachedProfile.query() .byName(profileName) .toIdOf(Profile.UserLicenseId); } ``` -------------------------------- ### Basic SOQL Cache Usage Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/cache/api/soql-cache.md Demonstrates the basic usage of SOQLCache to query and retrieve a single object with specified fields and a filter condition. ```apex SOQLCache.of(Profile.SObjectType) .with(Profile.Id, Profile.Name, Profile.UserType) .whereEqual(Profile.Name, 'System Administrator') .toObject(); ``` -------------------------------- ### Using Custom Profile Cache Selector Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/docs/getting-started.md Shows how to use the SOQL_ProfileCache selector to retrieve the 'System Administrator' profile and assign its ID to a new user. This leverages caching for performance. ```apex public with sharing class ExampleController { @AuraEnabled public static void createNewAdministrator(User newUser) { Profile adminProfile = (Profile) SOQL_ProfileCache.query() .byName('System Administrator') .toObject(); newUser.ProfileId = adminProfile.Id; insert newUser; } } ``` -------------------------------- ### Get Related Record IDs Source: https://github.com/beyond-the-cloud-dev/soql-lib/blob/main/website/docs/evaluator/api/soql-evaluator.md Extracts the IDs of related records based on a relationship name and a field. Ensure the relationship name and field are correctly specified. ```apex Set parentAccountIds = SOQLEvaluator.of([SELECT Id, Name, Parent.Id FROM Account WITH USER_MODE]).toIdsOf('Parent', Account.Id); ```