A tiny BSON database in Golang.
Go to file
Steve Domino a2e31af24c adding a mutex to getOrCreateMutex to avoid race conditions (per @chrhlnd pr) 2015-10-20 11:06:33 -06: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 adding a mutex to getOrCreateMutex to avoid race conditions (per @chrhlnd pr) 2015-10-20 11:06:33 -06:00
scribble.go adding a mutex to getOrCreateMutex to avoid race conditions (per @chrhlnd pr) 2015-10-20 11:06:33 -06:00
scribble_test.go cleaned up some logic, using filepath library when working with paths to have better support for windows (per @chrhlnd pull request). added tests to test looking for empty files/directories 2015-10-19 15:01:40 -06:00

README.md

scribble

golang-scribble (Golang package: scribble) is a tiny JSON flat file store

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 to which it can send any output.
db, err := scribble.New(dir, logger)
if err != nil {
  fmt.Println("Error", err)
}

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

}

// Read all fish from the database
fish := []Fish{}
if err := db.Read("/fish", fish); err != nil {

}

// Read a fish from the database
fish := Fish{}
if err := db.Read("/fish/onefish", fish); err != nil {

}

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

}

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

}

For an example of a qualified logger see here.

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