tree: b10aac24aa4ca6849b913ac4889e0f0ad16c3f82 [path history] [tgz]
  1. admin/
  2. internal/
  3. testdata/
  4. .release-please-manifest.json
  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. mutation.go
  23. mutation_test.go
  24. oc_test.go
  25. prop.go
  26. query.go
  27. query_test.go
  28. README.md
  29. release-please-config.json
  30. save.go
  31. save_test.go
  32. time.go
  33. time_test.go
  34. transaction.go
  35. transaction_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)
}