forked from GoogleCloudPlatform/golang-samples
/
indexes.go
42 lines (33 loc) · 808 Bytes
/
indexes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package sample
import (
"time"
"golang.org/x/net/context"
"google.golang.org/appengine/datastore"
)
// [START unindexed_properties]
type Person struct {
Name string
Age int `datastore:",noindex"`
}
// [END unindexed_properties]
// [START exploding_index_example_3]
type Widget struct {
X []int
Y []string
Date time.Time
}
func f(ctx context.Context) {
e2 := &Widget{
X: []int{1, 2, 3, 4},
Y: []string{"red", "green", "blue"},
Date: time.Now(),
}
k := datastore.NewIncompleteKey(ctx, "Widget", nil)
if _, err := datastore.Put(ctx, k, e2); err != nil {
// Handle error.
}
}
// [END exploding_index_example_3]