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
}
go get github.com/spatialcurrent/go-nosql
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.
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.
This work is distributed under the MIT License. See LICENSE file.