https://github.com/gernest/nutz
A cool way to work with bolt database buckets
https://github.com/gernest/nutz
bolt-database golang nutz
Last synced: 6 months ago
JSON representation
A cool way to work with bolt database buckets
- Host: GitHub
- URL: https://github.com/gernest/nutz
- Owner: gernest
- License: mit
- Created: 2015-04-11T23:44:11.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-19T07:02:51.000Z (almost 9 years ago)
- Last Synced: 2023-08-05T15:23:06.082Z (over 1 year ago)
- Topics: bolt-database, golang, nutz
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 12
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nutz [](https://drone.io/github.com/gernest/nutz/latest) [](https://godoc.org/github.com/gernest/nutz)[](https://coveralls.io/r/gernest/nutz)
nutz is a library for interacting with bolt databases. It removes the boilerplates and
stay faithful with the bolt database view of "simple API".## Where is nutz useful
- [x] You want to maintain more than one database
- [x] Your project uses nested buckets extensively.## Installation
```bash
go get github.com/gernest/nutz
```
## How to use```go
package mainimport (
"fmt""github.com/gernest/nutz"
)func main() {
databaseName := "my-databse.db"// ntz.NewStorage takes the same arguments as *bolt.Open. The differnce is with
// nutz nothing is opened.
db := nutz.NewStorage(databaseName, 0600, nil)// Creates a new record in the bucket library with key "lady morgana" and
// value []byte("A mist of avalon")
db.Create("library", "lady morgana", []byte("A mist of avalon"))// If you want to create a record which will be deep inside buckets. lets say
// you want to store a record for a teacher. The buckets will be like
// city>school>class>teacher.
db.Create("city", "john Doe", []byte("scientist"), "school", "class", "teacher")// Retrieving records from a bolt database.
d := db.Get("library", "lady morgana")fmt.Println(string(d.Data) == "A mist of avalon") //=> true
// lets check if there was any error
fmt.Println(d.Error) //=> nil// Retriving nested buckets .
n:=db.Get("city","john Doe","school","class","teacher")fmt.Println(string(n.Data)=="scientist") //=> true
// Lets delete the database
db.DeleteDatabase()}
```
# Contributing
Start with clicking the star button to make the author and his neighbors happy. Then fork it and submit a pull request for whatever change you want to be added to this project.
Or, open an issue for any questions.
# Author
Geofrey ErnestTwitter : [@gernesti](https://twitter.com/gernesti)
## License
This project is under the MIT License. See the [LICENSE](https://github.com/gernest/nutz/blob/master/LICENCE) file for the full license text.