Correct gaedatastore As-Lib Use


#1

Hello, I’m attempting to include Cayley in an appengine project with a datastore backend. I’m having difficulty finding examples of this use case, and my guesses must be wrong because nothing is added to my datastore.

My imports look like this:

github.com/cayleygraph/cayley
github.com/cayleygraph/cayley/graph
_ “github.com/cayleygraph/cayley/graph/gaedatastore
github.com/cayleygraph/cayley/quad

Then I copied the Quickstart As-Lib instruction code but added

graph.InitQuadStore(“gaedatastore”, “”, map[string]interface{}{“HTTPRequest”: r})

and replaced

store, err := cayley.NewMemoryGraph()

with

store, err := cayley.NewGraph(“gaedatastore”, “”, map[string]interface{}{“HTTPRequest”: r})

where r is the http.Request pointer.

Am I close?


#2

Hi @GreyhoundZero,

Sorry for a long wait. Because of GAE datastore specifics, the code to initialize the database effectively does nothing, except for creating a valid QuadStore for later use. After getting this database handle, you can call ForRequest function to get a connection to GAE datastore associated with a given request. Returned object is ready to use, so you can start writing data to it.


#3

Hi,

I’m still not able to get this to work. Could you perhaps provide an example of the code to set it up?


#4

I’ve the same problem: how to get this to work? :slight_smile: