import * as types from './types'; import { Schema as SchemaConfig, Model as ModelConfig, Field as FieldConfig } from './config'; export declare class Schema { database: types.Database; config: SchemaConfig; models: Model[]; tablePrefix?: RegExp; private modelMap; constructor(database: types.Database, config?: SchemaConfig); get sort(): { models: Model[]; fields: ForeignKeyField[]; }; deprefix(name: string): string; private getModelConfig; private addModel; model(name: string): Model | undefined; } interface Table extends types.Table { shortName: string; } export declare class Model { schema: Schema; name: string; fields: Field[]; table: Table; config: ModelConfig; primaryKey: UniqueKey; uniqueKeys: UniqueKey[]; pluralName: string; private fieldMap; constructor(schema: Schema, table: types.Table, config?: ModelConfig); private getFieldConfig; field(fullname: string): Field | undefined; keyField(): SimpleField | undefined; keyValue(row: types.Document): types.Value | undefined; valueOf(row: types.Document, name: string | SimpleField): types.Value | undefined; checkUniqueKey(row: types.Document, reject?: (value: any) => boolean): UniqueKey | null; getForeignKeyCount(model: Model): number; getOtherForeignKeyField(field: ForeignKeyField): ForeignKeyField | undefined; getForeignKeyOf(model: Model): ForeignKeyField | null; resolveConstraints(): void; isClosureField(field: ForeignKeyField): boolean; resolveRelatedFields(): void; private resolveFieldNameConflicts; private preferredAutoFieldNameWinner; private hasExplicitFieldName; private getUniqueAutoFieldName; private getAutoFieldNameCandidates; private addField; alias(field: string): string; } export declare class Field { name: string; model: Model; config: FieldConfig; uniqueKey?: UniqueKey; constructor(name: string, model: Model, config: FieldConfig); isUnique(): boolean; get fullname(): string; } export declare class SimpleField extends Field { formula?: string; column: types.Column; constructor(model: Model, column: types.Column, config: FieldConfig); } export declare class ComputedField extends Field { formula: any; constructor(model: Model, formula: any, name: string); } export declare class ForeignKeyField extends SimpleField { referencedField: SimpleField; relatedField?: RelatedField; constructor(model: Model, column: types.Column, config: FieldConfig); } export declare class RelatedField extends Field { referencingField: ForeignKeyField; throughField?: ForeignKeyField; constructor(field: ForeignKeyField); getTypeName(plural?: boolean): string; } export declare class UniqueKey { fields: SimpleField[]; primary: boolean; constructor(fields: Field[], primary?: boolean); name(): string; autoIncrement(): boolean | undefined; } export declare function isValue(value: any): boolean; export declare function getReferencingFields(model: Model): ForeignKeyField[]; export declare function setModelName(config: SchemaConfig, model: Model, name: string): void; export declare class LeafModel { model: Model; path: (ForeignKeyField | RelatedField)[]; constructor(model: Model, path: (ForeignKeyField | RelatedField)[]); } export declare function getLeafModel(model: Model, selectors: (string | string[])[]): LeafModel; export {};