From 183beb128694ebd7dd5f4ccd30b05b1647389fd4 Mon Sep 17 00:00:00 2001 From: Star Date: Fri, 13 Dec 2024 19:34:51 +0800 Subject: [PATCH] add table _deleted for make db --- db.go | 10 +++++++++- db_test.js | 14 ++++++++++---- go.mod | 19 +++++++++++-------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/db.go b/db.go index 3e88f28..9fd7642 100644 --- a/db.go +++ b/db.go @@ -186,7 +186,15 @@ func makeDBObject(conn *db.DB, tx *db.Tx) map[string]any { if u.FileExists(tryFile) { erDesc = u.ReadFileN(tryFile) } - if err := dao.MakeDBFromDesc(conn, erDesc, logger); err == nil { + if err := dao.MakeDBFromDesc(conn, erDesc+` + +_deleted +table v30 PK +id v30 PK +time dt ct +owner v30 I +data t +`, logger); err == nil { return nil } else { panic(vm.NewGoError(err)) diff --git a/db_test.js b/db_test.js index 155edfe..ea53ca0 100644 --- a/db_test.js +++ b/db_test.js @@ -1,13 +1,19 @@ import db from 'apigo.cc/gojs/db' -function main(testUserName){ +function main(testUserName) { db.setDefault('sqlite://test.db') db.make(` - User + User // {api} {select:isValid=1} id i AI - name t + name v100 // [i] + password v100 // [p] {-} + age i // [n] + sex v10 // [s:Female,Male] + memo t // [t] + isValid b // [c] + version ubi // `) - db.insert('User', {name: testUserName}) + db.insert('User', { name: testUserName }) let user = db.query1('SELECT * FROM User').result return user } diff --git a/go.mod b/go.mod index 327b92c..bbc8d6b 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,16 @@ module apigo.cc/gojs/db -go 1.18 +go 1.21 + +toolchain go1.22.5 require ( - apigo.cc/gojs v0.0.6 + apigo.cc/gojs v0.0.8 github.com/ssgo/dao v0.1.5 github.com/ssgo/db v1.7.11 github.com/ssgo/log v1.7.7 - github.com/ssgo/u v1.7.11 - modernc.org/sqlite v1.34.1 + github.com/ssgo/u v1.7.13 + modernc.org/sqlite v1.34.2 ) require ( @@ -28,11 +30,12 @@ require ( github.com/ssgo/config v1.7.9 // indirect github.com/ssgo/standard v1.7.7 // indirect github.com/ssgo/tool v0.4.27 // indirect - golang.org/x/sys v0.27.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect - modernc.org/libc v1.55.3 // indirect + modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 // indirect + modernc.org/libc v1.61.4 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect