REST Layer Google Datastore resource storage handler
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
datastore.go
example_test.go
lookup.go

README.md

REST Layer Google Datastore Backend

godoc license build

This REST Layer resource storage backend stores data in a Google Datastore using datastore.

This backend used cmorent/rest-layer-datastore as a base and borrows structure and approach from rs/rest-layer-mongo. It uses the general library rather than specific appengine library.

Usage

import "github.com/ajcrowe/rest-layer-datastore"

Or use gopkg.in for a more stable v1 release

import "gopkg.in/ajcrowe/rest-layer-datastore.v1"

Create a datastore client

ctx := context.Background()
client, err := datastore.NewClient(ctx, "project-id")
if err != nil {
	log.Fatalf("Error connecting to Datastore: %s", err)
}

Then use this to create a new Handler for your resource binds

// params for the handler
namespace := "default"
entity := "users"
// bind the users resource with the datastore handler
index.Bind("users", user, datastore.NewHandler(client, namespace, entity), resource.DefaultConf)

You can also set a number of Datastore properties which you would like to exclude from being indexed with SetNoIndexProperties on your handler struct.

// create a handler for the resource.
index.Bind("users", user, datastore.NewHandler(client, namespace, entity).SetNoIndexProperties([]string{"prop1", "prop2"}), resource.DefaultConf)

Supported filter operators

  • $and
  • $or
  • $lt
  • $lte
  • $gt
  • $gte
  • $in
  • $nin
  • $exists