A tiny JSON database in Golang
Install using go get github.com/nanobox-io/golang-scribble
.
// a new scribble driver, providing the directory where it will be writing to,
// and a qualified logger to which it can send any output.
db, err := scribble.New(dir, logger)
if err != nil {
fmt.Println("Error", err)
}
// Write a fish to the database
fish := Fish{}
if err := db.Write("fish", "onefish", fish); err != nil {
}
// Read all fish from the database
fish := []Fish{}
if err := db.Read("fish", "", fish); err != nil {
}
// Read a fish from the database
fish := Fish{}
if err := db.Read("fish", "onefish", fish); err != nil {
}
// Delete all fish from the database
if err := db.Delete("fish", ""); err != nil {
}
// Delete a fish from the database
if err := db.Delete("fish", "onefish"); err != nil {
}
For an example of a qualified logger see here.
Complete documentation is available on godoc.
- 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)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request