import { ConnectionInfo } from './engine'; import { FlushOptions } from './flush'; import { Record } from './record'; import { RecordConfig } from './loader'; import { Schema, Model, Field, SimpleField, ForeignKeyField, RelatedField, Column as ColumnInfo, Document, Value } from 'sqlex'; import { Schema as SchemaConfig } from 'sqlex/dist/config'; import { Connection, ConnectionPool, Row } from './engine'; export declare type Filter = Document | Document[]; import { QueryBuilder } from './filter'; import { FieldOptions } from './select'; export declare class ClosureTable { table: Table; ancestor: ForeignKeyField; descendant: ForeignKeyField; depth?: SimpleField; constructor(table: Table, ancestor: ForeignKeyField, descendant: ForeignKeyField, depth?: SimpleField); } export declare class Database { name: string; schema: Schema; pool: ConnectionPool; tableMap: { [key: string]: Table; }; tableList: Table[]; constructor(connection: ConnectionPool | ConnectionInfo, schema?: Schema); getModels(bulk?: boolean): { [key: string]: any; }; buildSchema(config?: SchemaConfig): Promise; clone(): Database; private setSchema; table(name: string | Field | Model): Table; model(name: string): Model; append(name: string, data: { [key: string]: any; }): any; getDirtyCount(): number; flush(flushOptions?: FlushOptions): Promise; end(): Promise; clear(): void; json(): {}; } export declare type OrderBy = string | string[]; export interface SelectOptions { where?: Filter; offset?: number; limit?: number; orderBy?: OrderBy; } export declare class Table { db: Database; name: string; model: Model; closureTable?: ClosureTable; recordList: Record[]; recordMap: { [key: string]: { [key: string]: Record; }; }; constructor(db: Database, model: Model); column(name: string): ColumnInfo; getParentField(model?: Model): ForeignKeyField; getAncestors(row: Value | Document, filter?: Filter): Promise; getDescendants(row: Value | Document, filter?: Filter): Promise; select(fields: string | Document, options?: SelectOptions, filterThunk?: (builder: QueryBuilder) => string, connection?: Connection): Promise; _resolveRelatedFields(connection: Connection, result: Document[], fields: string | Document): Promise; get(key: Value | Filter): Promise; insert(data: Row): Promise; create(data: Document): Promise; update(data: Document, filter: Filter): Promise; upsert(data: Document, update?: Document): Promise; modify(data: Document, filter: Filter): Promise; private _call; delete(filter: Filter): Promise; replace(data: Document): Promise; count(filter?: Filter, expr?: string): Promise; private _name; private _where; private _pair; private _select; _update(connection: Connection, fields: Document, filter: Filter): Promise; _insert(connection: Connection, data: Row): Promise; _delete(connection: Connection, filter: Filter): Promise; escapeName(name: SimpleField | string | number): string; escapeValue(field: SimpleField | string, value: Value): string; _get(connection: Connection, key: Value | Filter): Promise; _resolveParentFields(connection: Connection, input: Document, filter?: Filter): Promise; _create(connection: Connection, data: Document): Promise; private _upsert; private _modify; private _updateChildFields; private _updateChildField; _disconnectUnique(connection: Connection, field: SimpleField, id: Value): Promise; _connectThrough(connection: Connection, related: RelatedField, value: Value, args: Document[]): Promise; private _createThrough; private _upsertThrough; private _updateThrough; _deleteThrough(connection: Connection, related: RelatedField, value: Value, args: Document[]): Promise; _disconnectThrough(connection: Connection, related: RelatedField, value: Value, args: Document[]): Promise; claim(filter: Filter, data: Document, orderBy?: string[]): Promise; append(data?: { [key: string]: any; } | any[]): Record; clear(): void; getDirtyCount(): number; json(): {}[]; _mapGet(record: Record): Record; _mapPut(record: Record): void; _initMap(): void; _selectRelated(connection: Connection, field: RelatedField, values: Value[], fields: any, selectOptions: SelectOptions): Promise; xappend(data: Document | Document[], config: RecordConfig, defaults?: Document): Promise; xselect(config: RecordConfig, options?: SelectOptions): Promise; selectTree(filter: Filter, options?: FieldOptions): Promise; } export declare function _toCamel(value: Value, field: SimpleField): Value; export declare function toRow(value: Value, field: SimpleField): Value; export declare function toDocument(row: Row, model: Model, fieldMap?: {}): Document; export declare function isEmpty(value: Value | Record | any): any; export declare function shouldSelectSeparately(model: Model, fields: string | Document): boolean; export declare function getUniqueFields(model: Model, row: Document): {};