tree: 3fa718417d8fbaced985bfb35a3e432e778c8b44 [path history] [tgz]
  1. .repo-metadata.json
  2. CHANGES.md
  3. README.md
  4. client.go
  5. datastore.go
  6. datastore.replay
  7. datastore_test.go
  8. doc.go
  9. errors.go
  10. example_test.go
  11. go.mod
  12. go.sum
  13. go_mod_tidy_hack.go
  14. integration_test.go
  15. internal/
  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. save.go
  29. save_test.go
  30. testdata/
  31. time.go
  32. time_test.go
  33. transaction.go
  34. 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)
}