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-10-12 19:30:50 +00:00
|
|
|
// Read all fish from the database
|
|
|
|
fish := []Fish{}
|
2015-11-04 21:45:28 +00:00
|
|
|
if err := db.Read("fish", "", fish); err != nil {
|
2015-11-21 17:32:17 +00:00
|
|
|
fmt.Println("Error", err)
|
2015-07-07 23:37:08 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 19:30:50 +00:00
|
|
|
// Read a fish from the database
|
|
|
|
fish := Fish{}
|
2015-10-29 17:22:23 +00:00
|
|
|
if err := db.Read("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-10-12 19:30:50 +00:00
|
|
|
// Delete all fish from the database
|
2015-11-04 21:45:28 +00:00
|
|
|
if err := db.Delete("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-10-12 16:14:36 +00:00
|
|
|
## Documentation
|
|
|
|
Complete documentation is available on [godoc](http://godoc.org/github.com/nanobox-io/golang-scribble).
|
|
|
|
|
|
|
|
|
|
|
|
## 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-10-12 23:13:44 +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
|
|
|
|
1. Fork it
|
|
|
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
|
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
|
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
|
|
5. Create new Pull Request
|