2014-12-01 22:55:19 +00:00
scribble
2015-07-07 23:37:08 +00:00
--------
2015-11-13 21:21:11 +00:00
A tiny JSON database in Golang
2015-07-07 23:37:08 +00:00
### Installation
2015-09-29 15:15:17 +00:00
Install using `go get github.com/nanobox-io/golang-scribble` .
2015-07-07 23:37:08 +00:00
### Usage
2015-10-12 19:30:50 +00:00
```go
// a new scribble driver, providing the directory where it will be writing to,
2015-11-21 17:32:17 +00:00
// and a qualified logger if desired
db, err := scribble.New(dir, nil)
2015-10-12 19:30:50 +00:00
if err != nil {
fmt.Println("Error", err)
}
2015-07-07 23:37:08 +00:00
2015-10-12 19:30:50 +00:00
// Write a fish to the database
fish := Fish{}
2015-10-29 17:22:23 +00:00
if err := db.Write("fish", "onefish", fish); err != nil {
2015-11-21 17:32:17 +00:00
fmt.Println("Error", err)
2015-10-12 19:30:50 +00:00
}
2015-07-07 23:37:08 +00:00
2015-12-18 00:13:27 +00:00
// Read a fish from the database (passing fish by reference)
2015-10-12 19:30:50 +00:00
fish := []Fish{}
2015-12-18 00:13:27 +00:00
if err := db.Read("fish", "onefish", &fish); err != nil {
2015-11-21 17:32:17 +00:00
fmt.Println("Error", err)
2015-07-07 23:37:08 +00:00
}
2015-12-18 00:13:27 +00:00
// Read all fish from the database, unmarshaling the response.
records, err := db.ReadAll("fish")
if err != nil {
2015-11-21 17:32:17 +00:00
fmt.Println("Error", err)
2015-10-12 19:30:50 +00:00
}
2015-07-07 23:37:08 +00:00
2015-12-18 00:13:27 +00:00
fish := []Fish{}
2015-12-18 00:20:20 +00:00
if err := json.Unmarshal([]byte(records), &fish); err != nil {
2015-11-21 17:32:17 +00:00
fmt.Println("Error", err)
2015-10-12 19:30:50 +00:00
}
// Delete a fish from the database
2015-10-29 17:22:23 +00:00
if err := db.Delete("fish", "onefish"); err != nil {
2015-11-21 17:32:17 +00:00
fmt.Println("Error", err)
2015-07-07 23:37:08 +00:00
}
2015-12-18 00:13:27 +00:00
// Delete all fish from the database
if err := db.Delete("fish", ""); err != nil {
fmt.Println("Error", err)
}
2015-07-07 23:37:08 +00:00
```
2015-10-12 16:14:36 +00:00
## Documentation
2016-03-11 23:59:00 +00:00
Complete documentation is available on [godoc ](http://godoc.org/github.com/nanobox-io/golang-scribble ).
2015-10-12 16:14:36 +00:00
## Todo/Doing
2015-10-20 17:06:33 +00:00
- Support for windows
- Better support for concurrency
2015-10-12 19:30:50 +00:00
- Better support for sub collections
- More methods to allow different types of reads/writes
2015-12-18 00:13:27 +00:00
- More tests (you can never have enough!)
2015-10-12 16:06:42 +00:00
2015-10-12 16:14:36 +00:00
## Contributing
2016-03-11 23:59:00 +00:00
Contributions to scribble are welcome and encouraged. Scribble is a [Nanobox ](https://nanobox.io ) project and contributions should follow the [Nanobox Contribution Process & Guidelines ](https://docs.nanobox.io/contributing/ ).