File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,20 @@ func (db *DB) insertMany(query gjson.Result) (res string) {
69
69
70
70
//fmt.Println("bulk data: ", strData[:len(strData)-1])
71
71
72
- _ , err := db .db .Exec (`insert into ` + coll + `(record) values` + strData [:len (strData )- 1 ]) // fast
72
+ _ , err := db .db .Exec (`insert into ` + coll + `(record) values` + strData [:len (strData )- 1 ]) // `+` is fast
73
73
if err != nil {
74
74
db .lastid [coll ] = lid
75
+ if strings .Contains (err .Error (), "no such table" ) {
76
+ err = db .CreateCollection (coll )
77
+ if err != nil {
78
+ return err .Error ()
79
+ }
80
+ return db .insertMany (query )
81
+ }
75
82
return err .Error ()
76
83
}
77
84
78
- return "in progress "
85
+ return "inserted "
79
86
}
80
87
81
88
// insert new record
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ import (
13
13
var content embed.FS
14
14
15
15
func main () {
16
- // TODO close programe greatfully .
16
+ // TODO: Close program gracefully .
17
17
18
18
db := engine .NewDB ("test.db" )
19
- db .CreateCollection ("users " )
19
+ db .CreateCollection ("test " )
20
20
defer db .Close ()
21
21
22
22
fmt .Printf ("interacte with zaradb from %s:%s\n " , Host , Port )
You can’t perform that action at this time.
0 commit comments