tree: 97bd039878b9f2b59cc8f4cea48747466b122416 [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. go.mod
  10. go.sum
  11. go_mod_tidy_hack.go
  12. integration_test.go
  13. internal/
  14. key.go
  15. key_test.go
  16. keycompat.go
  17. keycompat_test.go
  18. load.go
  19. load_test.go
  20. mutation.go
  21. mutation_test.go
  22. oc_test.go
  23. prop.go
  24. query.go
  25. query_test.go
  26. save.go
  27. save_test.go
  28. testdata/
  29. time.go
  30. time_test.go
  31. transaction.go
  32. 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)
}