From 9cd64d91d0db3ee300be761cd3d2c97fec04e1b1 Mon Sep 17 00:00:00 2001 From: Star Date: Sun, 27 Oct 2024 00:36:18 +0800 Subject: [PATCH] add SetSSKey add makeInKeys --- db.go | 7 +++++++ db.ts | 64 +++++++++++++++++++++++++++++++---------------------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/db.go b/db.go index 481b53c..8f1927b 100644 --- a/db.go +++ b/db.go @@ -46,6 +46,9 @@ func init() { Desc: "db api by github.com/ssgo/db", TsCode: dbTS, Example: dbMD, + SetSSKey: func(key, iv []byte) { + db.SetEncryptKeys(key, iv) + }, }) } @@ -169,6 +172,10 @@ func makeDBObject(conn *db.DB, tx *db.Tx) map[string]any { panic(vm.NewGoError(r.Error)) } }, + "makeInKeys": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value { + args := gojs.MakeArgs(&argsIn, vm).Check(1) + return vm.ToValue(db.InKeys(args.Int(0))) + }, } if tx == nil { diff --git a/db.ts b/db.ts index e82f6fc..9a8e84d 100644 --- a/db.ts +++ b/db.ts @@ -14,46 +14,50 @@ export default { delete: delete_, destroy, begin, + makeInKeys, } -function get(dbName: string): DB {return null as any} -function setDefault(dbName: string): void {} -function make(descFileOrContent: string): Array{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} +function get(dbName: string): DB { return null as any } +function setDefault(dbName: string): void { } +function make(descFileOrContent: string): Array { 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 } +function makeInKeys(numKeys: number): string { return '' } interface DB { make(descFileOrContent: string): Array - 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 + 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 + makeInKeys(numKeys: number): string } 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 + 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 + makeInKeys(numKeys: number): string } interface QueryResult {