Skip to content

DatabaseLayerParameter__mdt

GitHub Action edited this page Mar 15, 2026 · 1 revision

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.

Fields

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

Available Parameters

The following parameters are recognized by the framework. Any other DeveloperName values are ignored.

DmlPreAndPostProcessor

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.

SoqlPreAndPostProcessor

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.

How Parameters Are Loaded

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.

Testing With Parameters

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();

apex-database-layer

Home

Core Concepts

Reference Guide

Migration Guides

Clone this wiki locally