tree: 821bc6e482e2f3e1c1ca473c5e8f6439df9a0244 [path history] [tgz]
  1. CHANGES.md
  2. README.md
  3. client.go
  4. datastore.go
  5. datastore.replay
  6. datastore_test.go
  7. doc.go
  8. errors.go
  9. example_test.go
  10. go.mod
  11. go.sum
  12. go_mod_tidy_hack.go
  13. integration_test.go
  14. internal/
  15. key.go
  16. key_test.go
  17. keycompat.go
  18. keycompat_test.go
  19. load.go
  20. load_test.go
  21. mutation.go
  22. mutation_test.go
  23. oc_test.go
  24. prop.go
  25. query.go
  26. query_test.go
  27. save.go
  28. save_test.go
  29. testdata/
  30. time.go
  31. time_test.go
  32. transaction.go
  33. 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)
}