A tiny BSON database in Golang.
Go to file
Steve Domino e941ae8fc9 turned down some logging 2016-03-07 19:29:06 -07:00
.gitignore first commit 2014-12-01 15:55:19 -07:00
LICENSE updating licensing 2015-06-02 08:46:25 -06:00
README.md updating readme 2015-12-17 17:20:20 -07:00
scribble.go turned down some logging 2016-03-07 19:29:06 -07:00
scribble_test.go cleaning up scribble new a bit from previous pull request. Updating/fixing tests 2015-11-23 11:37:37 -07:00

README.md

scribble

A tiny JSON database in Golang

Installation

Install using go get github.com/nanobox-io/golang-scribble.

Usage

// a new scribble driver, providing the directory where it will be writing to,
// and a qualified logger if desired
db, err := scribble.New(dir, nil)
if err != nil {
  fmt.Println("Error", err)
}

// Write a fish to the database
fish := Fish{}
if err := db.Write("fish", "onefish", fish); err != nil {
  fmt.Println("Error", err)
}

// Read a fish from the database (passing fish by reference)
fish := []Fish{}
if err := db.Read("fish", "onefish", &fish); err != nil {
  fmt.Println("Error", err)
}

// Read all fish from the database, unmarshaling the response.
records, err := db.ReadAll("fish")
if err != nil {
  fmt.Println("Error", err)
}

fish := []Fish{}
if err := json.Unmarshal([]byte(records), &fish); err != nil {
  fmt.Println("Error", err)
}

// Delete a fish from the database
if err := db.Delete("fish", "onefish"); err != nil {
  fmt.Println("Error", err)
}

// Delete all fish from the database
if err := db.Delete("fish", ""); err != nil {
  fmt.Println("Error", err)
}

Documentation

Complete documentation is available on godoc.

Todo/Doing

  • Support for windows
  • Better support for concurrency
  • Better support for sub collections
  • More methods to allow different types of reads/writes
  • More tests (you can never have enough!)

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