Configuration Keys
Every db-gen configuration key, organized by area. For how the config file is located and merged, see Configuration.
Source of truth
The schema is defined by the Config struct in ../db-gen/private/dbGen/config.go. Boolean keys default to false unless noted.
Connection & output
| Key |
Type |
Default |
Description |
ConnectionString |
string |
— |
PostgreSQL connection string. Overridable with --connectionString. |
OutputFolder |
string |
— |
Folder for generated files. Relative to the config file's directory. Created if missing. |
ModelsFolderName |
string |
"models" |
Subfolder (under OutputFolder) for models. |
ProcessorsFolderName |
string |
"processors" |
Subfolder for processors. |
GeneratedFileExtension |
string |
— |
Extension for generated files (e.g. .cs, .go, .ts). |
GeneratedFileCase |
string |
— |
Filename case: snakecase / camelcase / pascalcase. Required (validated). |
ClearOutputFolder |
bool |
false |
Delete the output folder's contents before generating. Mutually exclusive with RemoveOrphanedFiles. |
RemoveOrphanedFiles |
bool |
false |
Remove previously generated files whose database function no longer exists. Tracks all output folders. Only works when ClearOutputFolder is false. |
What to generate
| Key |
Type |
Default |
Description |
GenerateModels |
bool |
false |
Generate model types for routine return shapes. |
GenerateProcessors |
bool |
false |
Generate processors (db reader → model mappers). |
GenerateProcessorsForVoidReturns |
bool |
false |
Also generate a processor for functions that return nothing. |
Generate |
array |
— |
Schema/function selection — see below. |
Mappings |
array |
— |
Type mappings — see Type Mapping. |
Templates
| Key |
Type |
Description |
DbContextTemplate |
string |
Template for the database-call code. Path relative to config dir. |
ModelTemplate |
string |
Template for model files. |
ProcessorTemplate |
string |
Template for processor files. |
Offline generation
| Key |
Type |
Default |
Description |
RoutinesFile |
string |
"./db-gen-routines.json" |
Path to the JSON routine-definitions file. |
UseRoutinesFile |
bool |
false |
Read routines from RoutinesFile instead of connecting. |
Context parameters
| Key |
Type |
Default |
Description |
UseUserContext |
bool |
false |
Enable context-parameter mapping. |
UserContextParameterName |
string |
"ctx" |
Name of the context parameter in generated code. |
UserContextType |
string |
"UserContext" |
Type of the context parameter. |
ContextParameterMappings |
array |
— |
Maps db parameter names to context paths. |
ContextParameterMappings[]:
| Field |
Type |
Description |
ParameterNames |
string[] |
Database parameter names to treat as context. |
ContextPath |
string |
Property path on the context object (e.g. User.UserId). |
Additional generators
AdditionalGenerators[]:
| Field |
Type |
Description |
Name |
string |
Generator name (for logging). |
Enabled |
bool |
Whether to run it. |
Template |
string |
Template path. |
OutputFolder |
string |
Output folder. |
FileName |
string |
File name (single-file generation). |
FileExtension |
string |
File extension (per-routine generation). |
FileCase |
string |
snakecase / camelcase / pascalcase. |
GenerationType |
string |
single-file or per-routine. Inferred from FileName if omitted. |
CleanOutputFolder |
bool |
Delete the output folder before generating. |
Copy targets
| Key |
Type |
Default |
Description |
GenerateCopyTargets |
bool |
false |
Enable copy-target generation. |
CopyTargetTemplate |
string |
— |
Template for copy-target files. |
CopyTargetsFolderName |
string |
"copy" |
Subfolder under OutputFolder. |
CopyTargets |
array |
— |
Tables to generate for. |
CopyTargets[]:
| Field |
Type |
Description |
Schema / Table |
string |
The table to read columns from. |
MappedName |
string |
Override the generated struct/file name. |
Format |
string |
csv (default) / text / binary — hint for the template. |
NullString |
string |
NULL sentinel for text/CSV formats. |
Generate
Generate[] (schema selection):
| Field |
Type |
Description |
Schema |
string |
Database schema name. |
AllFunctions |
bool |
Generate all functions except those set to false in Functions. |
Functions |
object |
Map of function name → true/false or an override object. Key may be name or name(args). |
Functions[] override object:
| Field |
Type |
Description |
MappedName |
string |
Override generated name (required for overloads). |
DontRetrieveValues |
bool |
Disable value retrieval (off-only). |
SelectOnlySpecified |
bool |
Select only explicitly listed model columns. |
Model |
object |
Per-column overrides (MappedName, MappedType, MappingFunction, IsNullable) or false to skip. |
Parameters |
object |
Per-parameter overrides (MappedName, MappedType, IsNullable, IsOptional). |
Mappings
Mappings[] (type mapping; last entry wins on conflict, "*" is the fallback):
| Field |
Type |
Description |
DatabaseTypes |
string[] |
PostgreSQL udt_names this entry covers. "*" = catch-all. |
MappedType |
string |
Base type (non-nullable, non-optional). |
MappingFunction |
string |
Function used to read the value from the db reader. |
NullableReturnType |
string |
Type for nullable return values / model properties. |
NullableParameterType |
string |
Type for nullable parameters without a DEFAULT. |
OptionalParameterType |
string |
Type for optional parameters with a DEFAULT. |
See Type Mapping for resolution rules.
Validation
Validation configures the validation subsystem:
| Field |
Type |
Description |
ValidationStrategy |
string |
e.g. Manual, FluentValidation. |
ValidationLocations |
string[] |
Where to emit validation (e.g. Controller, Provider). |
ValidationBehavior |
object |
CollectAllErrors (bool), ReturnType (string), ErrorResponseTemplate (string). |
ValidationRuleDefinitions |
array |
Reusable rule definitions. |
ParameterValidationMappings |
array |
Map rules to parameter names globally. |
FunctionSpecificValidations |
object |
Per-function rule overrides. |