-
Notifications
You must be signed in to change notification settings - Fork 460
Safely
pozil edited this page Nov 14, 2024
·
10 revisions
Class wraps DML Calls in FLS / Crud checks. Library is baseed on
a fluent api system. All calls are constructed, then chained with options.
For instances. new Safely().allOrNothing().doInsert(List<sObject>);
Notable chainable methods include:
- allOrNothing() - this enforces the AllOrNothing DML flag. All DML is eventually executed via Database.* methods which accept an allOrNothing parameter requiring all of the records to succeed or fail.
- throwIfRemovedFields() - this method, if called, will result in an exception being thrown if any record being modified has fields removed by the security decision.
TESTVISIBLE
private allOrNothing
Boolean
TESTVISIBLE
private throwIfRemovedFields
Boolean
public Safely allOrNothing()
public Safely throwIfRemovedFields()
public List<Database.SaveResult> doInsert(List<SObject> records)
Name | Type | Description |
---|---|---|
records | List<SObject> |
List<Database.SaveResult>
public List<Database.SaveResult> doInsert(SObject record)
Name | Type | Description |
---|---|---|
record | SObject |
List<Database.SaveResult>
public List<Database.SaveResult> doUpdate(List<SObject> records)
Name | Type | Description |
---|---|---|
records | List<SObject> |
List<Database.SaveResult>
public List<Database.SaveResult> doUpdate(SObject record)
Name | Type | Description |
---|---|---|
record | SObject |
List<Database.SaveResult>
public List<Database.UpsertResult> doUpsert(List<SObject> records)
Name | Type | Description |
---|---|---|
records | List<SObject> |
List<Database.UpsertResult>
public List<Database.UpsertResult> doUpsert(Sobject record)
Name | Type | Description |
---|---|---|
record | Sobject |
List<Database.UpsertResult>
public List<Database.DeleteResult> doDelete(List<SObject> records)
Name | Type | Description |
---|---|---|
records | List<SObject> |
List<Database.DeleteResult>
public List<Database.DeleteResult> doDelete(SObject record)
Name | Type | Description |
---|---|---|
record | SObject |
List<Database.DeleteResult>
public List<SObject> doQuery(String query)
Name | Type | Description |
---|---|---|
query | String |
List<SObject>
private List<Database.SaveResult> doDML(System.AccessType accessType, List<SObject> records)
Name | Type | Description |
---|---|---|
accessType | System.AccessType | |
records | List<SObject> |
List<Database.SaveResult>
private SObjectAccessDecision guardAgainstRemovedFields(System.AccessType accessType, List<SObject> records)
Name | Type | Description |
---|---|---|
accessType | System.AccessType | |
records | List<SObject> |
SObjectAccessDecision