Awesome
REST Layer Google Datastore Backend
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