import { Database, Dialect } from '../../base/index.js'; import { RelatedModel } from './model.js'; import { QueryParams, BuildQueryResult, CreateQueryParams, SelectQueryParams, InsertQueryParams, InsertManyQueryParams, UpdateQueryParams, DeleteQueryParams, AlterQueryParams, DropTableQueryParams, DropIndexQueryParams, AggregateQueryParams, Condition, Column, AddDefinition, ModifyDefinition, DropDefinition, JoinClause, RelationsConfig } from '../../types.js'; /** * 关系型数据库类 * 支持表、行、列的关系型数据模型 */ export declare class RelatedDatabase = Record> extends Database { /** 关系配置 */ protected relationsConfig?: RelationsConfig; constructor(dialect: Dialect, definitions?: Database.DefinitionObj, relations?: RelationsConfig); /** * 设置关系配置 * @example * ```ts * db.defineRelations({ * users: { * hasMany: { orders: 'userId' }, * hasOne: { profile: 'userId' } * }, * orders: { * belongsTo: { users: 'userId' } * } * }); * ``` */ defineRelations(config: RelationsConfig): this; protected initialize(): Promise; buildQuery(params: QueryParams): BuildQueryResult; protected buildCreateQuery(params: CreateQueryParams): BuildQueryResult; protected buildSelectQuery(params: SelectQueryParams): BuildQueryResult; /** * 格式化 JOIN 子句 */ protected formatJoinClause(mainTable: string, join: JoinClause): string; protected buildInsertQuery(params: InsertQueryParams): BuildQueryResult; protected buildInsertManyQuery(params: InsertManyQueryParams): BuildQueryResult; protected buildUpdateQuery(params: UpdateQueryParams): BuildQueryResult; protected buildDeleteQuery(params: DeleteQueryParams): BuildQueryResult; protected buildAlterQuery(params: AlterQueryParams): BuildQueryResult; protected buildDropTableQuery(params: DropTableQueryParams): BuildQueryResult; protected buildDropIndexQuery(params: DropIndexQueryParams): BuildQueryResult; protected buildAggregateQuery(params: AggregateQueryParams): BuildQueryResult; protected formatColumnDefinition(field: string, column: Column): string; protected formatAlteration(field: string, alteration: AddDefinition | ModifyDefinition | DropDefinition): string; /** * 解析条件对象为 SQL WHERE 子句 * @param condition 条件对象 * @param tablePrefix 表名前缀(用于 JOIN 查询) */ protected parseCondition(condition: Condition, tablePrefix?: string): [string, any[]]; /** * 获取模型 * @param name 模型名称 * @param options 可选的模型选项(如 softDelete, timestamps) */ model(name: T, options?: import('../../types.js').ModelOptions): RelatedModel; /** * 应用关系配置到模型 */ private applyRelationsToModel; /** * 获取所有模型名称 */ getModelNames(): string[]; } //# sourceMappingURL=database.d.ts.map