Skip to content

GoStore is a small but powerful storage interface for nosql/some rdbms* databases like RethinkDb, boltdb, leveldb, riak, mongodb, postgres* etc.

Notifications You must be signed in to change notification settings

osiloke/gostore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

GoStore is your applications data swiss knife

** NOTE: This project is currently being reworked. The old code can be found in the deprecated folder **

Build Status GoDoc

GoStore is an application storage tool used to speed up your application development. It makes it easier to mix and match existing nosql/some rdbms* databases like RethinkDb, boltdb, leveldb, riak, mongodb, postgres* etc into your application. It attempts to create a simple way to use different combinations of storage backends in an api. The idea is to standardize high level database operations that are common to every application.

*RDBMS support is still experimental

Features:

  • Support go1.5+
  • Generalized api for accessing multiple types of databases
  • Uses best practices for manipulating data tailored to each type of database
  • Application level filtering for databases that dont support filtering (BoltDB)
  • Semantic easily understandable api to perform application store actions

Still being developed, so the api might change slightly, but don't be afraid to post an issue. I use this in an existing project anyway.

database implementations can be found at gostore-contrib

Supported Databases

Eventually Supported Databases

  • CockroachDb
  • MongoDB
  • Aerospike
  • Couch

Usage

$ go get github.com/osiloke/gostore

Gostore tries to simplify your database needs by providing simple specific highlevel database actions which are common to most applications. These actions form the api and are listed below

#####Using a store

import (
	"github.com/osiloke/gostore"
)
//Create a rethinkdb backed store called app
store, _ := gostore.NewRethinkObjectStoreAndSession("localhost:28015", "app")

//Now create the db
store.CreateDatabase()

//Create the table you want to use, you can pass an optional schema
//to do some advanced stuff
store.CreateTable("things", nil)

//now for profit, tables are accessed by name

//Save a thing which returns the stored key
key, _ := store.Save("things", map[string]interface{}{"name":"one thing", "kind": "table"})

//Or just save all things
keys, _ := store.SaveAll("things", []interface{}{
	map[string]interface{}{"name": "First Thing", "kind": "chair"},
	map[string]interface{}{"name": "Second Thing", "kind": "cup"},
})
keys = append(keys, key)
//Now we can retrieve a thing
var thing map[string]interface{}
store.Get(key, "things", &thing)

println(thing)

Api

####Database Operations

  • CreateDatabase - Creates the database
  • CreateTable - Creates a table/container/collection in a database
  • GetStore - This returns a reference to the stores session
  • Stats - Gets some stats on the database
  • Close - Closes the database, essentially closing the session

####Retrieval

  • All
  • AllCursor
  • AllWithinRange
  • Get

####Creation and Updates

  • Save
  • SaveAll
  • Update
  • Replace
  • Delete

####Filtering

  • Since
  • Before
  • FilterSince
  • FilterBefore
  • FilterBeforeCount
  • FilterUpdate
  • FilterReplace
  • FilterGet
  • FilterGetAll
  • FilterDelete
  • BatchFilterDelete
  • FilterCounts
  • GetByField
  • GetByFieldsByField

Testing

This project uses goconvey for testing but you can run tests like any other go project

go test -v

Testing rethinkdb store requires a running rethink server. This will be updated to use a mock rethinkdb in a few days after which this comment will be removed

Contributors

Contributors on GitHub

License

Version

  • Version 0.1

Contact

Developer/Company

Flattr this git repo

About

GoStore is a small but powerful storage interface for nosql/some rdbms* databases like RethinkDb, boltdb, leveldb, riak, mongodb, postgres* etc.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages