50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import {
|
|
type KyselyPlugin,
|
|
type PluginTransformQueryArgs,
|
|
type PluginTransformResultArgs,
|
|
type QueryResult,
|
|
type RootOperationNode,
|
|
type UnknownRow,
|
|
} from 'kysely';
|
|
import type { SqlEntityManager } from '../SqlEntityManager.js';
|
|
/** Configuration options for the MikroKyselyPlugin. */
|
|
export interface MikroKyselyPluginOptions {
|
|
/**
|
|
* Use database table names ('table') or entity names ('entity') in queries.
|
|
*
|
|
* @default 'table'
|
|
*/
|
|
tableNamingStrategy?: 'table' | 'entity';
|
|
/**
|
|
* Use database column names ('column') or property names ('property') in queries.
|
|
*
|
|
* @default 'column'
|
|
*/
|
|
columnNamingStrategy?: 'column' | 'property';
|
|
/**
|
|
* Automatically process entity `onCreate` hooks in INSERT queries.
|
|
*
|
|
* @default false
|
|
*/
|
|
processOnCreateHooks?: boolean;
|
|
/**
|
|
* Automatically process entity `onUpdate` hooks in UPDATE queries.
|
|
*
|
|
* @default false
|
|
*/
|
|
processOnUpdateHooks?: boolean;
|
|
/**
|
|
* Convert JavaScript values to database-compatible values (e.g., Date to timestamp, custom types).
|
|
*
|
|
* @default false
|
|
*/
|
|
convertValues?: boolean;
|
|
}
|
|
/** Kysely plugin that transforms queries and results to use MikroORM entity/property naming conventions. */
|
|
export declare class MikroKyselyPlugin implements KyselyPlugin {
|
|
#private;
|
|
constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
|
|
transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
|
|
transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
|
|
}
|