-
Notifications
You must be signed in to change notification settings - Fork 0
DatabaseLayerParameter__mdt
The DatabaseLayerParameter__mdt custom metadata type provides optional named configuration parameters for the Apex Database Layer framework. Each record represents a single parameter, identified by its DeveloperName, with a string Value__c field.
Note: This object is optional — you do not need to create any records to enable the framework's core functionality.
| Field | API Name | Type | Description |
|---|---|---|---|
| Label | MasterLabel |
Text | A human-readable label for this parameter record |
| DeveloperName | DeveloperName |
Text | The unique name used by the framework to look up this parameter |
| Value | Value__c |
Text (255) | The string value for this parameter (e.g., an Apex class name) |
| Description | Description__c |
Long Text Area (1000) | An optional description of what this parameter controls |
The following parameters are recognized by the framework. Any other DeveloperName values are ignored.
| Purpose | Registers a plugin to run before and after every DML operation |
| Value | Fully-qualified Apex class name implementing Dml.PreAndPostProcessor
|
| Example Value | MyDmlLogger |
See Plugin: Dml.PreAndPostProcessor for full setup instructions.
| Purpose | Registers a plugin to run before and after every SOQL operation |
| Value | Fully-qualified Apex class name implementing Soql.PreAndPostProcessor
|
| Example Value | MySoqlLogger |
See Plugin: Soql.PreAndPostProcessor for full setup instructions.
Parameters are read at runtime using DatabaseLayerParameter__mdt.getInstance() — no SOQL is consumed. The framework caches the results for the duration of the transaction.
To re-read parameters after mocking them in a test (e.g., after calling MockCmdt.mock()), call DatabaseLayer.Utils.Plugins.init() to flush the cache and reload.
Use DatabaseLayerTestUtils.initDmlAndSoqlPlugins to mock both plugin parameters in a single call:
@IsTest
static void myTest() {
DatabaseLayerTestUtils.initDmlAndSoqlPlugins('MyPluginClassName');
// ... test logic
}To mock individual parameters, use MockCmdt directly:
DatabaseLayerParameter__mdt mockParam = new DatabaseLayerParameter__mdt(
DeveloperName = 'DmlPreAndPostProcessor',
Value__c = 'MyDmlPlugin'
);
MockCmdt.mock(DatabaseLayerParameter__mdt.SObjectType)?.add(mockParam);
DatabaseLayer.Utils.Plugins.init();- Generating Test Records
- Dml
- Soql
- Cmdt
- Duplicates
- Plugins
- DatabaseLayer
- DatabaseLayerTestUtils
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- Duplicates
- MockDuplicates
- 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