db/db.ts

83 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-10-11 11:32:50 +08:00
// just for develop
export default {
get,
setDefault,
make,
query,
query1,
query11,
exec,
insert,
replace,
update,
delete: delete_,
destroy,
begin,
}
function get(dbName: string): DB {return null as any}
function setDefault(dbName: string): void {}
function make(descFileOrContent: string): Array<Object>{return null as any}
function query(sql: string, ...args:any): QueryResult{return null as any}
function query1(sql: string, ...args:any): QueryResult1{return null as any}
function query11(sql: string, ...args:any): QueryResult11{return null as any}
function exec(sql: string, ...args:any): ExecResult{return null as any}
function insert(table: string, data:Object): ExecResult{return null as any}
function replace(table: string, data:Object): ExecResult{return null as any}
function update(table: string, data:Object, where: string, ...args:any): ExecResult{return null as any}
function delete_(table: string, where: string, ...args:any): ExecResult{return null as any}
function destroy(): void{}
function begin(): Tx{return null as any}
interface DB {
make(descFileOrContent: string): Array<Object>
query(sql: string, ...args:any): QueryResult
query1(sql: string, ...args:any): QueryResult1
query11(sql: string, ...args:any): QueryResult11
exec(sql: string, ...args:any): ExecResult
insert(table: string, data:Object): ExecResult
replace(table: string, data:Object): ExecResult
update(table: string, data:Object, where: string, ...args:any): ExecResult
delete(table: string, where: string, ...args:any): ExecResult
destroy(): void
begin(): Tx
}
interface Tx {
query(sql: string, ...args:any): QueryResult
query1(sql: string, ...args:any): QueryResult1
query11(sql: string, ...args:any): QueryResult11
exec(sql: string, ...args:any): ExecResult
insert(table: string, data:Object): ExecResult
replace(table: string, data:Object): ExecResult
update(table: string, data:Object, where: string, ...args:any): ExecResult
delete(table: string, where: string, ...args:any): ExecResult
end(ok:boolean): void
}
interface QueryResult {
sql: string
args: Array<any>
result: Array<Object>
}
interface QueryResult1 {
sql: string
args: Array<any>
result: Object
}
interface QueryResult11 {
sql: string
args: Array<any>
result: any
}
interface ExecResult {
sql: string
args: Array<any>
id: number
changes: number
}