This commit is contained in:
2022-07-14 14:39:59 -04:00
parent 66079e5e03
commit 1567035954
3 changed files with 108 additions and 69 deletions

View File

@ -31,6 +31,7 @@ type Item struct {
}
type Jdb struct {
Foo string `json:"-"`
Items []Item `json:"items"`
}
@ -72,7 +73,7 @@ func (d *Db) Transact(id int, persist bool, f func(*Item)) error {
}
func (d *Db) save() error {
data, err := json.Marshal(Jdb{d.items})
data, err := json.Marshal(Jdb{"", d.items})
if err != nil {
return err
}
@ -82,7 +83,7 @@ func (d *Db) save() error {
func (d *Db) Run(f func(*Jdb)) {
d.mutex.Lock()
defer d.mutex.Unlock()
f(&Jdb{d.items})
f(&Jdb{"", d.items})
}
func (d *Db) Save() error {