# Safely Class 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);` 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. ## Fields ### `allOrNothing` `TESTVISIBLE` #### Signature ```apex private allOrNothing ``` #### Type Boolean --- ### `throwIfRemovedFields` `TESTVISIBLE` #### Signature ```apex private throwIfRemovedFields ``` #### Type Boolean ## Methods ### `allOrNothing()` #### Signature ```apex public Safely allOrNothing() ``` #### Return Type **[Safely](Safely.md)** --- ### `throwIfRemovedFields()` #### Signature ```apex public Safely throwIfRemovedFields() ``` #### Return Type **[Safely](Safely.md)** --- ### `doInsert(records)` #### Signature ```apex public List doInsert(List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | records | List<SObject> | | #### Return Type **List<Database.SaveResult>** --- ### `doInsert(record)` #### Signature ```apex public List doInsert(SObject record) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | record | SObject | | #### Return Type **List<Database.SaveResult>** --- ### `doUpdate(records)` #### Signature ```apex public List doUpdate(List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | records | List<SObject> | | #### Return Type **List<Database.SaveResult>** --- ### `doUpdate(record)` #### Signature ```apex public List doUpdate(SObject record) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | record | SObject | | #### Return Type **List<Database.SaveResult>** --- ### `doUpsert(records)` #### Signature ```apex public List doUpsert(List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | records | List<SObject> | | #### Return Type **List<Database.UpsertResult>** --- ### `doUpsert(record)` #### Signature ```apex public List doUpsert(Sobject record) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | record | Sobject | | #### Return Type **List<Database.UpsertResult>** --- ### `doDelete(records)` #### Signature ```apex public List doDelete(List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | records | List<SObject> | | #### Return Type **List<Database.DeleteResult>** --- ### `doDelete(record)` #### Signature ```apex public List doDelete(SObject record) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | record | SObject | | #### Return Type **List<Database.DeleteResult>** --- ### `doQuery(query)` #### Signature ```apex public List doQuery(String query) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | query | String | | #### Return Type **List<SObject>** --- ### `doDML(accessType, records)` #### Signature ```apex private List doDML(System.AccessType accessType, List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | accessType | System.AccessType | | | records | List<SObject> | | #### Return Type **List<Database.SaveResult>** --- ### `guardAgainstRemovedFields(accessType, records)` #### Signature ```apex private SObjectAccessDecision guardAgainstRemovedFields(System.AccessType accessType, List records) ``` #### Parameters | Name | Type | Description | |------|------|-------------| | accessType | System.AccessType | | | records | List<SObject> | | #### Return Type **SObjectAccessDecision** ## Classes ### RemovedFieldsException Class