add SetSSKey

add makeInKeys
This commit is contained in:
Star 2024-10-27 00:36:18 +08:00
parent a527592867
commit 9cd64d91d0
2 changed files with 41 additions and 30 deletions

7
db.go
View File

@ -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 {

4
db.ts
View File

@ -14,6 +14,7 @@ export default {
delete: delete_,
destroy,
begin,
makeInKeys,
}
function get(dbName: string): DB { return null as any }
@ -29,6 +30,7 @@ function update(table: string, data:Object, where: string, ...args:any): ExecRes
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<Object>
@ -42,6 +44,7 @@ interface DB {
delete(table: string, where: string, ...args: any): ExecResult
destroy(): void
begin(): Tx
makeInKeys(numKeys: number): string
}
interface Tx {
@ -54,6 +57,7 @@ interface Tx {
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 {