tree: c0e1428a9732d65842599d7b8d1a1c9b8c95533b [path history] [tgz]
  1. admin/
  2. aliasshim/
  3. internal/
  4. testdata/
  5. CHANGES.md
  6. client.go
  7. datastore.go
  8. datastore.replay
  9. datastore_test.go
  10. doc.go
  11. errors.go
  12. example_test.go
  13. go.mod
  14. go.sum
  15. integration_test.go
  16. key.go
  17. key_test.go
  18. keycompat.go
  19. keycompat_test.go
  20. load.go
  21. load_test.go
  22. mock_test.go
  23. mutation.go
  24. mutation_test.go
  25. oc_test.go
  26. prop.go
  27. prop_test.go
  28. query.go
  29. query_test.go
  30. README.md
  31. save.go
  32. save_test.go
  33. time.go
  34. time_test.go
  35. transaction.go
  36. transaction_test.go
  37. util_test.go
datastore/README.md

Cloud Datastore Go Reference

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)
}