@naturalcycles/mysql-lib
Version:
MySQL client implementing CommonDB interface
27 lines (26 loc) • 1.05 kB
TypeScript
import type { JsonSchemaObject, JsonSchemaRootObject } from '@naturalcycles/js-lib/json-schema';
import type { CommonLogger } from '@naturalcycles/js-lib/log';
import type { AnyObject } from '@naturalcycles/js-lib/types';
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: JsonSchemaObject<any>, opt?: MySQLSchemaOptions): string;
export declare function mysqlTableStatsToJsonSchemaField<T extends AnyObject = any>(table: string, stats: MySQLTableStats[], logger: CommonLogger): JsonSchemaRootObject<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;