dynamo-browse/internal/dynamo-browse/providers/settingstore/settingstore.go
Leon Mika 93ec519127
Issue 24: Added read-only mode (#27)
- Added settings to workspace, and added the read-only mode
- Added the `-ro` field which will launch Dynamo-Browse in read-only mode
- Added the `set ro` to enable read-only mode, and `set rw` to enable read-write mode
2022-09-29 22:10:18 +10:00

32 lines
567 B
Go

package settingstore
import (
"github.com/asdine/storm"
"github.com/lmika/audax/internal/common/workspaces"
)
const settingBucket = "Settings"
const (
keyTableReadOnly = "table_ro"
)
type SettingStore struct {
ws storm.Node
}
func New(ws *workspaces.Workspace) *SettingStore {
return &SettingStore{
ws: ws.DB(),
}
}
func (c *SettingStore) IsReadOnly() (b bool, err error) {
err = c.ws.Get(settingBucket, keyTableReadOnly, &b)
return b, err
}
func (c *SettingStore) SetReadOnly(ro bool) error {
return c.ws.Set(settingBucket, keyTableReadOnly, ro)
}