Scribble
A tiny JSON database in Golang
Installation
Install using go get github.com/sdomino/scribble
.
Usage
db, err := scribble.New(dir, nil)
if err != nil {
fmt.Println("Error", err)
}
fish := Fish{}
if err := db.Write("fish", "onefish", fish); err != nil {
fmt.Println("Error", err)
}
onefish := Fish{}
if err := db.Read("fish", "onefish", &onefish); err != nil {
fmt.Println("Error", err)
}
records, err := db.ReadAll("fish")
if err != nil {
fmt.Println("Error", err)
}
fishies := []Fish{}
for _, f := range records {
fishFound := Fish{}
if err := json.Unmarshal([]byte(f), &fishFound); err != nil {
fmt.Println("Error", err)
}
fishies = append(fishies, fishFound)
}
if err := db.Delete("fish", "onefish"); err != nil {
fmt.Println("Error", err)
}
if err := db.Delete("fish", ""); err != nil {
fmt.Println("Error", err)
}
Documentation
- Complete documentation is available on godoc.
- Coverage Report is available on gocover
Todo/Doing
- Support for windows
- Better support for concurrency
- Better support for sub collections
- More methods to allow different types of reads/writes
- More tests (you can never have enough!)