• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..02-Sep-2021-

admin/apiv1/H02-Sep-2021-1,295736

internal/gaepb/H02-Sep-2021-433394

testdata/H02-Sep-2021-4135

CHANGES.mdH A D02-Sep-20212.9 KiB5133

README.mdH A D02-Sep-20211.3 KiB4235

client.goH A D02-Sep-20214.8 KiB14099

datastore.goH A D02-Sep-202120.2 KiB682501

datastore_test.goH A D02-Sep-202172.2 KiB3,5733,315

doc.goH A D02-Sep-202116 KiB5111

errors.goH A D02-Sep-20211.2 KiB4825

example_test.goH A D02-Sep-202113.8 KiB594442

go.modH A D02-Sep-2021358 1512

go.sumH A D02-Sep-202152.4 KiB536535

go_mod_tidy_hack.goH A D02-Sep-2021939 242

integration_test.goH A D02-Sep-202132.8 KiB1,3351,151

key.goH A D02-Sep-20217 KiB294207

key_test.goH A D02-Sep-20214.9 KiB211184

keycompat.goH A D02-Sep-20211.8 KiB6738

keycompat_test.goH A D02-Sep-20211.7 KiB5637

load.goH A D02-Sep-202115.2 KiB564433

load_test.goH A D02-Sep-202127.3 KiB1,2351,114

mutation.goH A D02-Sep-20213.6 KiB13595

mutation_test.goH A D02-Sep-20213.5 KiB151132

oc_test.goH A D02-Sep-20211.1 KiB4423

prop.goH A D02-Sep-20219.5 KiB340206

query.goH A D02-Sep-202122.5 KiB789547

query_test.goH A D02-Sep-202114.3 KiB571492

save.goH A D02-Sep-202114.2 KiB526422

save_test.goH A D02-Sep-202110.1 KiB495448

time.goH A D02-Sep-20211.2 KiB3715

time_test.goH A D02-Sep-20212.4 KiB7655

transaction.goH A D02-Sep-202112.9 KiB413274

transaction_test.goH A D02-Sep-20212.1 KiB7860

README.md

1## Cloud Datastore [![Go Reference](https://pkg.go.dev/badge/cloud.google.com/go/datastore.svg)](https://pkg.go.dev/cloud.google.com/go/datastore)
2
3- [About Cloud Datastore](https://cloud.google.com/datastore/)
4- [Activating the API for your project](https://cloud.google.com/datastore/docs/activate)
5- [API documentation](https://cloud.google.com/datastore/docs)
6- [Go client documentation](https://pkg.go.dev/cloud.google.com/go/datastore)
7- [Complete sample program](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/datastore/tasks)
8
9### Example Usage
10
11First create a `datastore.Client` to use throughout your application:
12
13[snip]:# (datastore-1)
14```go
15client, err := datastore.NewClient(ctx, "my-project-id")
16if err != nil {
17	log.Fatal(err)
18}
19```
20
21Then use that client to interact with the API:
22
23[snip]:# (datastore-2)
24```go
25type Post struct {
26	Title       string
27	Body        string `datastore:",noindex"`
28	PublishedAt time.Time
29}
30keys := []*datastore.Key{
31	datastore.NameKey("Post", "post1", nil),
32	datastore.NameKey("Post", "post2", nil),
33}
34posts := []*Post{
35	{Title: "Post 1", Body: "...", PublishedAt: time.Now()},
36	{Title: "Post 2", Body: "...", PublishedAt: time.Now()},
37}
38if _, err := client.PutMulti(ctx, keys, posts); err != nil {
39	log.Fatal(err)
40}
41```
42