Config types
SqlCrudConfig and DrizzleCrudConfig — the two interfaces that drive the module.
The package exposes two config types: DrizzleCrudConfig (the input to forRoot / forRootAsync) and SqlCrudConfig (the merged, per-entity config the base class actually uses).
DrizzleCrudConfig
The input to DrizzleCrudModule.forRoot(config) and forRootAsync. It describes the project-level configuration: the database connection, schema, and global defaults.
interface DrizzleCrudConfig {
/** Required. */
: 'postgresql' | 'mysql';
/** PostgreSQL: connection string. The module builds the connection. */
?: string;
/** Any dialect: pre-built Drizzle instance. Required for MySQL. */
?: any;
/** Required when building from connectionString. */
?: <string, unknown>;
/** Per-project defaults applied to every entity unless overridden. */
?: {
?: boolean;
?: boolean;
?: { : number; : number };
?: 'asc' | 'desc';
};
/** Dialect tuning. */
?: {
?: boolean;
?: boolean;
?: boolean;
?: boolean;
};
}Defaults
defaults: {
softDelete: true,
timestamps: true,
pagination: { defaultLimit: 20, maxLimit: 100 },
// sortOrder: opt-in (no fallback)
}
sql: {
caseSensitive: false,
useReturning: dialect === 'postgresql',
jsonSupport: true,
enableFullTextSearch: false,
}SqlCrudConfig
The fully-resolved, per-entity configuration. The package constructs this by layering:
global defaults (DrizzleCrudConfig)
→ @CrudService decorator metadata
→ forFeature { config }
→ db, table (set by forFeature)interface SqlCrudConfig {
// ---- Set by the module ----
: 'postgresql' | 'mysql';
: any;
: any;
// ---- Primary key ----
: string; // default 'id'
:
| 'serial' | 'bigserial' | 'int' | 'bigint' | 'uuid';
// ---- Soft delete ----
?: {
: boolean;
: string; // e.g. 'deleted_at'
};
// ---- Timestamps ----
?: {
: string; // e.g. 'created_at'
: string; // e.g. 'updated_at'
};
// ---- Pagination ----
?: {
: number;
: number;
};
// ---- Default ORDER BY ----
?: <{
: string;
: 'asc' | 'desc';
}>;
// ---- Dialect tuning ----
?: {
: boolean;
: boolean;
: boolean;
: boolean;
};
// ---- Many-to-one / one-to-one relations ----
?: <
string,
{
: any;
: string;
?: string;
}
>;
}RelationConfig and RelationsConfig
interface RelationConfig {
: any; // the target Drizzle table
: string; // the FK column on the *current* table
?: string; // the column on the target table (defaults to 'id')
}
type = <string, RelationConfig>;SqlSearchOptions
SqlOperationOptions.search is accepted by findAll and count.
type = 'ilike' | 'fullText';
interface SqlSearchOptions {
: string;
: string[];
?: ;
}The default mode is ilike, which searches each configured column with a
contains-style pattern and joins the column predicates with OR. fullText is
PostgreSQL-only and compiles to to_tsvector(...) @@ plainto_tsquery(...).
CrudFeature
The input to forFeature:
interface CrudFeature {
: typeof ;
: any; // Drizzle table
?: <SqlCrudConfig>; // per-entity overrides
}config is SqlCrudConfig minus db and dialect (those are injected by forFeature).
SqlDialect, PrimaryKeyType, SortColumn, SortOrder
type = 'postgresql' | 'mysql';
type = 'serial' | 'bigserial' | 'int' | 'bigint' | 'uuid';
type = 'asc' | 'desc';
interface SortColumn { : string; : }