UNPKG

@naturalcycles/mysql-lib

Version:

MySQL client implementing CommonDB interface

27 lines (26 loc) 999 B
import type { CommonLogger } from '@naturalcycles/js-lib/log'; import type { AnyObject } from '@naturalcycles/js-lib/types'; import type { JsonSchema } from '@naturalcycles/nodejs-lib/ajv'; export interface MySQLTableStats { Field: string; Type: string; Null: string; } export interface MySQLSchemaOptions { /** * @default 'InnoDB' */ engine?: string; } /** * It currently skips nullability and declares everything as "DEFAULT NULL". */ export declare function jsonSchemaToMySQLDDL(table: string, schema: JsonSchema<any>, opt?: MySQLSchemaOptions): string; export declare function mysqlTableStatsToJsonSchemaField<T extends AnyObject = any>(table: string, stats: MySQLTableStats[], logger: CommonLogger): JsonSchema<T>; /** * Because MySQL doesn't support `.` in field names and escapes them as tableName + fieldName. * * @param name */ export declare function mapNameToMySQL(name: string): string; export declare function mapNameFromMySQL(name: string): string;