2014-12-01 17:55:19 -05:00
|
|
|
scribble
|
2015-07-07 19:37:08 -04:00
|
|
|
--------
|
|
|
|
|
|
|
|
`golang-scribble` (Golang package: `scribble`) is a tiny JSON flat file store
|
|
|
|
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2015-09-29 11:15:17 -04:00
|
|
|
Install using `go get github.com/nanobox-io/golang-scribble`.
|
2015-07-07 19:37:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
```go
|
|
|
|
// 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)
|
|
|
|
}
|
2015-07-07 19:37:08 -04:00
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
// Write a fish to the database
|
|
|
|
fish := Fish{}
|
2015-10-29 13:22:23 -04:00
|
|
|
if err := db.Write("fish", "onefish", fish); err != nil {
|
2015-07-07 19:37:08 -04:00
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
}
|
2015-07-07 19:37:08 -04:00
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
// Read all fish from the database
|
|
|
|
fish := []Fish{}
|
2015-10-29 13:22:23 -04:00
|
|
|
if err := db.Read("fish", fish); err != nil {
|
2015-07-07 19:37:08 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
// Read a fish from the database
|
|
|
|
fish := Fish{}
|
2015-10-29 13:22:23 -04:00
|
|
|
if err := db.Read("fish", "onefish", fish); err != nil {
|
2015-10-12 15:30:50 -04:00
|
|
|
|
|
|
|
}
|
2015-07-07 19:37:08 -04:00
|
|
|
|
2015-10-12 15:30:50 -04:00
|
|
|
// Delete all fish from the database
|
2015-10-29 13:22:23 -04:00
|
|
|
if err := db.Delete("fish"); err != nil {
|
2015-10-12 15:30:50 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete a fish from the database
|
2015-10-29 13:22:23 -04:00
|
|
|
if err := db.Delete("fish", "onefish"); err != nil {
|
2015-07-07 19:37:08 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-09-29 11:15:17 -04:00
|
|
|
For an example of a qualified logger see [here](http://godoc.org/github.com/nanobox-io/golang-hatchet).
|
2015-07-07 19:37:08 -04:00
|
|
|
|
|
|
|
|
2015-10-12 12:14:36 -04:00
|
|
|
## Documentation
|
|
|
|
Complete documentation is available on [godoc](http://godoc.org/github.com/nanobox-io/golang-scribble).
|
|
|
|
|
|
|
|
|
|
|
|
## Todo/Doing
|
2015-10-20 13:06:33 -04:00
|
|
|
- Support for windows
|
|
|
|
- Better support for concurrency
|
2015-10-12 15:30:50 -04:00
|
|
|
- Better support for sub collections
|
|
|
|
- More methods to allow different types of reads/writes
|
2015-10-12 19:13:44 -04:00
|
|
|
- More tests (you can never have enough)
|
2015-10-12 12:06:42 -04:00
|
|
|
|
|
|
|
|
2015-10-12 12:14:36 -04: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
|