tree: 67f0af9ebcaa94528d00afd5bd887ca520bd5543 [path history] [tgz]
  1. README.md
  2. client.go
  3. datastore.go
  4. datastore.replay
  5. datastore_test.go
  6. doc.go
  7. errors.go
  8. example_test.go
  9. integration_test.go
  10. internal/
  11. key.go
  12. key_test.go
  13. keycompat.go
  14. keycompat_test.go
  15. load.go
  16. load_test.go
  17. mutation.go
  18. mutation_test.go
  19. oc_test.go
  20. prop.go
  21. query.go
  22. query_test.go
  23. save.go
  24. save_test.go
  25. testdata/
  26. time.go
  27. time_test.go
  28. transaction.go
  29. transaction_test.go
datastore/README.md

Cloud Datastore GoDoc

Example Usage

First create a datastore.Client to use throughout your application:

client, err := datastore.NewClient(ctx, "my-project-id")
if err != nil {
	log.Fatal(err)
}

Then use that client to interact with the API:

type Post struct {
	Title       string
	Body        string `datastore:",noindex"`
	PublishedAt time.Time
}
keys := []*datastore.Key{
	datastore.NameKey("Post", "post1", nil),
	datastore.NameKey("Post", "post2", nil),
}
posts := []*Post{
	{Title: "Post 1", Body: "...", PublishedAt: time.Now()},
	{Title: "Post 2", Body: "...", PublishedAt: time.Now()},
}
if _, err := client.PutMulti(ctx, keys, posts); err != nil {
	log.Fatal(err)
}