DataStore
The forvendi.DataStore class provides a centralized data-caching and lazy-loading mechanism for database queries. It stores queried data in-memory, eliminates redundant SOQL queries, and supports both dynamic field requests and custom loader extensions.
Usage Example
public static void dataStoreExample() {
Account acc = new Account(Name = 'Breezz Test');
insert acc;
// 1. Create DataStore instance
forvendi.DataStore store = forvendi.BreezzApi.DATABASE.createDataStore();
// 2. Register custom loader (extends forvendi.DataStore.Loader)
store.registerLoader(new AccountTaskLoader());
// 3. Request data to be loaded for a specific record ID
store.requestToLoad(acc.Id);
// 4. Load requested data in bulk
store.loadData();
// 5. Store additional arbitrary objects manually
store.storeData('testObject', acc);
// 6. Retrieve stored data
Account testAcc = (Account) store.getFromStore(acc.Id);
}DataStore()
Default constructor initializing an empty DataStore instance.
Signature:
public DataStore()registerLoader(Loader loader)
Registers a custom loader instance into the loaders set for custom SOQL query execution.
Signature:
public forvendi.DataStore registerLoader(forvendi.DataStore.Loader loader)Parameters:
loader: Custom loader instance extendingforvendi.DataStore.Loader.
Return Value: forvendi.DataStore – Self-reference for method chaining.
requestFields(String storeKey, Set<String> fields)
Requests specific field API names to be loaded into the specified store bucket.
Signature:
public void requestFields(String storeKey, Set<String> fields)Parameters:
storeKey: Name of the store bucket.fields: Set of requested field API names.
requestToLoad Methods
Overloaded methods to register record IDs, custom string keys, or SObject fields for bulk querying.
public void requestToLoad(String storeKey, String key, Set<String> fields)
public void requestToLoad(String storeKey, String key)
public void requestToLoad(String storeKey, Id key, Set<String> fields)
public void requestToLoad(String storeKey, Id key, Set<SObjectField> fields)
public void requestToLoad(String storeKey, Id key)
public void requestToLoad(Id key, Set<String> fields)
public void requestToLoad(Id key, Set<SObjectField> fields)
public void requestToLoad(Id key)
public void requestToLoad(List<Id> ids, Set<String> fields)
public void requestToLoad(List<Id> ids)Parameters:
storeKey: Name of the store bucket (defaults to SObjectType derived fromId).key/ids: Record ID, string identifier, or list of IDs to load.fields: Requested fields specified as string API names orSObjectFieldtokens.
loadData()
Executes bulk queries for all accumulated data load requests using dynamic SObject and registered custom loaders.
Signature:
public void loadData()getKeys(String storeKey)
Returns all unique string keys contained within the specified store bucket.
Signature:
public Set<String> getKeys(String storeKey)Return Value: Set<String> – Set of unique store keys.
getIds(SObjectType type)
Returns all Record IDs stored within the bucket corresponding to the given SObjectType.
Signature:
public Set<Id> getIds(SObjectType type)Return Value: Set<Id> – Set of record IDs.
getIds(String storeKey)
Returns all Record IDs stored within the specified store bucket.
Signature:
public Set<Id> getIds(String storeKey)