-
Notifications
You must be signed in to change notification settings - Fork 0
Performing DML Operations
Jason Siders edited this page Jul 4, 2025
·
15 revisions
Performing DML using apex-database-layer is simple!
DatabaseLayer.Dml wraps the standard Database class, and has 1:1 parity with its DML methods.
To leverage the framework, simply use the DatabaseLayer.Dml equivalent of any Database DML method. In most cases, this means prefixing each method with "do" - since insert, update, etc. are reserved keywords in apex:
// Don't use these standard Database methods or DML keywords:
insert account;
Database.insert(account);
Database.insert(account, false);
Database.insert(account, false, System.AccessLevel.SYSTEM_MODE);
// Use the DatabaseLayer.Dml equivalent:
DatabaseLayer.Dml.doInsert(account);
DatabaseLayer.Dml.doInsert(account, false);
DatabaseLayer.Dml.doInsert(account, false, System.AccessLevel.SYSTEM_MODE);We recommend using DatabaseLayer.Dml instead of Database methods or standard DML keywords across your entire codebase. This practice has the following benefits:
- Easily mock DML operations in tests, usually with just a single line of code!
- Enables plugin functionality, which optionally runs logic before/after each DML operation (for example, logging).
- Generating Test Records
- Dml
- Soql
- Cmdt
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause