@sqb/connect
Version:
Multi-dialect database connection framework written with TypeScript
56 lines (55 loc) • 1.73 kB
TypeScript
import { DataType } from '@sqb/builder';
import { Type } from 'ts-gems';
import type { FieldInfoMap } from '../../client/field-info-map.js';
import { SqbConnection } from '../../client/sqb-connection.js';
import { ColumnTransformFunction } from '../orm.type.js';
import type { Repository } from '../repository.class.js';
import type { FindCommand } from './find.command.js';
export interface ValueProperty {
fieldAlias: string;
dataType?: DataType;
parse?: ColumnTransformFunction;
}
export interface ObjectProperty {
converter: RowConverter;
type: Type;
}
export interface NestedProperty {
converter: RowConverter;
type: Type;
parentField: string;
keyField: string;
findCommand: FindCommand;
sort?: string[];
paramValues: any[];
}
export declare class RowConverter {
resultType: Type;
parent?: RowConverter | undefined;
private _properties;
private _propertyKeys?;
constructor(resultType: Type, parent?: RowConverter | undefined);
addValueProperty(args: {
name: string;
fieldAlias: string;
dataType?: DataType;
parse?: ColumnTransformFunction;
}): ValueProperty;
addObjectProperty(args: {
name: string;
type: Type;
}): ObjectProperty;
addNestedProperty(args: {
name: string;
type: Type;
findCommand: FindCommand;
parentField: string;
keyField: string;
sort?: string[];
}): NestedProperty;
get keys(): string[];
transform(connection: SqbConnection, fields: FieldInfoMap, rows: any, onTransform?: Repository.TransformRowFunction): Promise<any[]>;
private _rowToObject;
private _iterateForNested;
private _checkCircularDep;
}