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
|
|
|
|
|
|
|
|
Create a 'transaction' for scribble to transact.
|
|
|
|
|
|
|
|
`t := scribble.Transaction{Action: "read", Collection: "records", ResourceID: "<UniqueID>", Container: &v}`
|
|
|
|
|
|
|
|
+ Action - the action for scribble to perform
|
|
|
|
+ write - write to the scribble db
|
|
|
|
+ read - read from the scribble db
|
|
|
|
+ readall - read from the scribble db (all files in a collection)
|
|
|
|
+ delete - remove a record from the scribble db
|
|
|
|
+ Collection - the folder scribble will create to store grouped records
|
|
|
|
+ ResourceID - the unique ID of the resource being stored (bson, uuid, etc.)
|
|
|
|
+ Container - the Struct that contains the data scribble will marshal into the store, or what it will unmarshal into from the store
|
|
|
|
|
|
|
|
|
|
|
|
#### Full Example
|
|
|
|
```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.
|
|
|
|
database, err := scribble.New(dir, logger)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is what scribble will either marshal from when writing, or unmarshal into when reading
|
|
|
|
record := Record{}
|
|
|
|
|
|
|
|
// create a new transaction for scribble to run
|
2015-10-12 14:14:54 -04:00
|
|
|
t := scribble.Transaction{Action: scribble.READ, Collection: "records", ResourceID: "<UniqueID>", Container: &record}
|
2015-07-07 19:37:08 -04:00
|
|
|
|
|
|
|
// have scribble attempt to run the transaction
|
|
|
|
if err := database.Transact(t); err != nil {
|
|
|
|
fmt.Println("Error", err)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
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-12 12:06:42 -04:00
|
|
|
- Tests!
|
|
|
|
|
|
|
|
|
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
|