Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 1.95 KB

README.md

File metadata and controls

77 lines (55 loc) · 1.95 KB

go-nosql

Description

go-nosql is a simplified wrapper for NoSQL databases that provides a common API interface. As it is a simplified wrapper, it cannot cover all database-specific features. Each database wrapped implements the NOSQLBackend interface. DynamoDB and MongoDB are currently supported.

Struct Table is used when calling CreateTables as DynamoDB requires defining Global Secondary Indexes. Each attribute is assumed to be a string.

Table === MongoDB Collection for the purposes of this API.

type Table struct {
  Name string
  Indexes []string
}

Installation

go get github.com/spatialcurrent/go-nosql

Usage

Import

import (
  "github.com/spatialcurrent/go-nosql/nosql"
)

Local DynamoDB

backend = &nosql.BackendDynamoDB{}
err := backend.Connect(map[string]string{
  "AWSDefaultRegion": "us-west-1",
  "StorefrontDynamoDBUrl": "http://localhost:8082",
})

Remote DynamoDB

backend = &nosql.BackendDynamoDB{}
err := backend.Connect(map[string]string{
  "AWSAccessKeyId": "",
  "AWSSecretAccessKey": "",
  "AWSSessionToken": "",
  "AWSDefaultRegion": "us-west-1",
})

MongoDB

backend = &nosql.BackendMongoDB{}
err := backend.Connect(map[string]string{
  "DatabaseUri": "localhost",
  "DatabaseName": "main",
  "Limit": "1000",
})

API

See Backend.go for the public APIs for each backend.

Contributing

Spatial Current, Inc. is currently accepting pull requests for this repository. We'd love to have your contributions! Please see Contributing.md for how to get started.

License

This work is distributed under the MIT License. See LICENSE file.