/// /// /// /// /// /// /// declare namespace FxOrmDMLDriver { type DriverUidType = string interface QueryDataPayload { [key: string]: any } interface QueriedCountDataPayload { c: number } interface DMLDriverOptions { // useless now pool?: boolean debug?: boolean settings: FxOrmSettings.SettingInstance } interface DMLDriverConstructor { new (config: FxDbDriverNS.DBConnectionConfig, connection: FxOrmDb.DatabaseBase, opts: FxOrmDMLDriver.DMLDriverOptions): DMLDriver prototype: DMLDriver } interface DMLDriver { readonly db: FxOrmDb.DatabaseBase readonly config: FxOrmDb.DatabaseBase['config'] customTypes: {[key: string]: FxOrmProperty.CustomPropertyType} knex: FXJSKnex.FXJSKnexModule.KnexInstance readonly query: FxSqlQuery.Class_Query /** * @deprecated */ getQuery: { (): FxSqlQuery.Class_Query } readonly ddlDialect: FxOrmSqlDDLSync__Dialect.Dialect /* shared :start */ doSync (opts?: FxOrmDMLShared.SyncOptions): this doDrop (opts?: FxOrmDMLShared.DropOptions): this /* shared :end */ connect: { (cb: FxOrmNS.GenericCallback): void (): FxDbDriverNS.Driver } reconnect: { (cb: FxOrmNS.GenericCallback): void (): FxDbDriverNS.Driver } ping: { (cb?: FxOrmNS.VoidCallback): void } on: { (ev: string, cb?: FxOrmNS.GenericCallback): void } close: { (cb?: FxOrmNS.VoidCallback): void } /** * @description * aggregate_functions could be string tuple such as * * [`RANDOM`, `RAND`] ---> FxOrmDb.AGGREGATION_METHOD_TUPLE__COMMON */ aggregate_functions: ( (FxOrmDb.AGGREGATION_METHOD_COMPLEX) | FxOrmDb.AGGREGATION_METHOD_TUPLE__COMMON )[] execSimpleQuery: { (query: string, cb?: FxOrmNS.GenericCallback): T } /** * @description do eager-query */ eagerQuery: { (association: FxOrmAssociation.InstanceAssociationItem, opts: FxOrmQuery.ChainFindOptions, keys: string[], cb?: FibOrmNS.GenericCallback): T } find: { (fields: FxSqlQueryColumns.SelectInputArgType[], table: string, conditions: FxSqlQuerySubQuery.SubQueryConditions, opts: DMLDriver_FindOptions, cb?: FxOrmNS.GenericCallback): T } count: { /** * mysql: {c: number} * sqlite: {c: number} */ (table: string, conditions: FxSqlQuerySubQuery.SubQueryConditions, opts: DMLDriver_CountOptions, cb?: FxOrmNS.GenericCallback): FxOrmQuery.CountResult[] } insert: { (table: string, data: FxSqlQuerySql.DataToSet, keyProperties: FxOrmProperty.NormalizedProperty[], cb?: FxOrmNS.GenericCallback): FxOrmQuery.InsertResult } update: { (table: string, changes: FxSqlQuerySql.DataToSet, conditions: FxSqlQuerySubQuery.SubQueryConditions, cb?: FxOrmNS.GenericCallback): T } remove: { (table: string, conditions: FxSqlQuerySubQuery.SubQueryConditions, cb?: FxOrmNS.GenericCallback): T } clear: { (table: string, cb?: FxOrmNS.GenericCallback): T } poolQuery: { (query: string, cb?: FxOrmNS.GenericCallback): T } valueToProperty: { (value: any, property: FxOrmProperty.NormalizedProperty): any } propertyToValue: { (value: any, property: FxOrmProperty.NormalizedProperty): any } readonly isSql: boolean /* patched :start */ // uniq id uid: string hasMany?: { (Model: FxOrmModel.Model, association: FxOrmAssociation.InstanceAssociationItem): any } execQuerySync: (query: string, opt: Fibjs.AnyObject) => any /* patched :end */ [ext_key: string]: any } /* ============================= DMLDriver API Options :start ============================= */ // type ChainWhereExistsInfoPayload = {[key: string]: FxOrmQuery.ChainWhereExistsInfo} | FxOrmQuery.ChainWhereExistsInfo[] type ChainWhereExistsInfoPayload = FxOrmQuery.ChainWhereExistsInfo[] interface DMLDriver_FindOptions { offset?: number limit?: number order?: FxOrmQuery.OrderNormalizedResult[] merge?: FxOrmQuery.ChainFindMergeInfo[] exists?: ChainWhereExistsInfoPayload } interface DMLDriver_CountOptions { merge?: DMLDriver_FindOptions['merge'] exists?: DMLDriver_FindOptions['exists'] } /* ============================= DMLDriver API Options :end ============================= */ /* ============================= typed db :start ============================= */ interface DMLDriverConstructor_MySQL extends DMLDriverConstructor { (this: DMLDriver_MySQL, config: FxDbDriverNS.DBConnectionConfig, connection: FxOrmDb.DatabaseBase, opts: FxOrmDMLDriver.DMLDriverOptions): void prototype: DMLDriver_MySQL } interface DMLDriver_MySQL extends DMLDriver { db: FxOrmDb.DatabaseBase aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_MYSQL | FxOrmDb.AGGREGATION_METHOD_TUPLE__MYSQL)[] } interface DMLDriverConstructor_PostgreSQL extends DMLDriverConstructor { (this: DMLDriver_PostgreSQL, config: FxDbDriverNS.DBConnectionConfig, connection: FxOrmDb.DatabaseBase_PostgreSQL, opts: FxOrmDMLDriver.DMLDriverOptions): void prototype: DMLDriver_PostgreSQL } interface DMLDriver_PostgreSQL extends DMLDriver { db: FxOrmDb.DatabaseBase_PostgreSQL aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_POSTGRESQL)[] } interface DMLDriverConstructor_SQLite extends DMLDriverConstructor { (this: DMLDriver_SQLite, config: FxDbDriverNS.DBConnectionConfig, connection: FxOrmDb.DatabaseBase_SQLite, opts: FxOrmDMLDriver.DMLDriverOptions): void prototype: DMLDriver_SQLite } interface DMLDriver_SQLite extends DMLDriver { db: FxOrmDb.DatabaseBase_SQLite aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_SQLITE)[] } /* ============================= typed db :end ============================= */ // type DefaultSqlDialect = FxOrmSqlDDLSync__Dialect.Dialect type DefaultSqlDialect = FxOrmSqlDDLSync__Dialect.Dialect } declare namespace FxOrmDMLShared { interface SyncOptions { id: string[] extension: boolean table: string allProperties: FxOrmProperty.NormalizedPropertyHash indexes: string[] customTypes: { [key: string]: FxOrmProperty.CustomPropertyType; } one_associations: FxOrmAssociation.InstanceAssociationItem_HasOne[] many_associations: FxOrmAssociation.InstanceAssociationItem_HasMany[] extend_associations: FxOrmAssociation.InstanceAssociationItem_ExtendTos[] /** * @default true */ repair_column?: boolean /** * @default false */ allow_drop_column?: boolean } interface DropOptions { table: string properties: FxOrmProperty.NormalizedPropertyHash one_associations: FxOrmAssociation.InstanceAssociationItem_HasOne[] many_associations: FxOrmAssociation.InstanceAssociationItem_HasMany[] } }