Documentation
¶
Overview ¶
Package aedatastore provides AppEngine Datastore implementation of datastore.Client. This package wrapping google.golang.org/appengine/v2/datastore package.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext make new Client by specified context.
Example ¶
inst, err := aetest.NewInstance(&aetest.Options{StronglyConsistentDatastore: true, SuppressDevAppServerLog: true}) if err != nil { panic(err) } defer inst.Close() r, err := inst.NewRequest("GET", "/", nil) if err != nil { panic(err) } ctx := appengine.NewContext(r) client, err := aedatastore.FromContext( ctx, ) if err != nil { panic(err) } defer client.Close() type Data struct { Name string } key := client.IncompleteKey("Data", nil) entity := &Data{Name: "mercari"} key, err = client.Put(ctx, key, entity) if err != nil { panic(err) } entity = &Data{} err = client.Get(ctx, key, entity) if err != nil { panic(err) } fmt.Println(entity.Name)
Output: mercari
func IsAEDatastoreClient ¶
IsAEDatastoreClient returns check result that client is this package's client or not.
func TransactionContext ¶
func TransactionContext(tx w.Transaction) context.Context
TransactionContext returns context that is under the AppEngine Datastore's transaction.
Example ¶
ctx, cancelFn := appengineContext() go cancelFn() client, err := aedatastore.FromContext(ctx) if err != nil { panic(err) } defer client.Close() tx, err := client.NewTransaction(ctx) if err != nil { panic(err) } go tx.Commit() txCtx := aedatastore.TransactionContext(tx) // join task to Transaction! task := taskqueue.NewPOSTTask("/foobar", url.Values{}) _, err = taskqueue.Add(txCtx, task, "") if err != nil { panic(err) }
Output:
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.