OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "golang.org/x/net/context" | 8 "golang.org/x/net/context" |
9 ) | 9 ) |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Note that in exchange for userfriendliness, this interface ends up doing | 38 // Note that in exchange for userfriendliness, this interface ends up doing |
39 // a lot of reflection. | 39 // a lot of reflection. |
40 // | 40 // |
41 // Methods taking 'interface{}' objects describe what a valid type for that | 41 // Methods taking 'interface{}' objects describe what a valid type for that |
42 // interface are in the comments. | 42 // interface are in the comments. |
43 // | 43 // |
44 // Struct objects passed in will be converted to PropertyLoadSaver interfaces | 44 // Struct objects passed in will be converted to PropertyLoadSaver interfaces |
45 // using this package's GetPLS function. | 45 // using this package's GetPLS function. |
46 type Interface interface { | 46 type Interface interface { |
47 // AllocateIDs allows you to allocate IDs from the datastore without put
ting | 47 // AllocateIDs allows you to allocate IDs from the datastore without put
ting |
48 » // any data. `incomplete` must be a PartialValid Key. If there's no erro
r, | 48 » // any data. The supplied keys must be PartialValid and share the same e
ntity |
49 » // a contiguous block of IDs of n length starting at `start` will be res
erved | 49 » // type. |
50 » // indefinitely for the user application code for use in new keys. The | 50 » // |
51 » // appengine automatic ID generator will never automatically assign thes
e IDs | 51 » // If there's no error, a new slice of complete keys will be returned wi
th |
52 » // for Keys of this type. | 52 » // reserved integer IDs // assigned to them. The appengine automatic ID |
53 » AllocateIDs(incomplete *Key, n int) (start int64, err error) | 53 » // generator will never automatically assign these IDs to any other Keys
of |
| 54 » // this type. |
| 55 » AllocateIDs(keys ...*Key) ([]*Key, error) |
54 | 56 |
55 // KeyForObj extracts a key from src. | 57 // KeyForObj extracts a key from src. |
56 // | 58 // |
57 // It is the same as KeyForObjErr, except that if KeyForObjErr would hav
e | 59 // It is the same as KeyForObjErr, except that if KeyForObjErr would hav
e |
58 // returned an error, this method panics. It's safe to use if you know t
hat | 60 // returned an error, this method panics. It's safe to use if you know t
hat |
59 // src statically meets the metadata constraints described by KeyForObjE
rr. | 61 // src statically meets the metadata constraints described by KeyForObjE
rr. |
60 KeyForObj(src interface{}) *Key | 62 KeyForObj(src interface{}) *Key |
61 | 63 |
62 // MakeKey is a convenience method for manufacturing a *Key. It should o
nly be | 64 // MakeKey is a convenience method for manufacturing a *Key. It should o
nly be |
63 // used when elems... is known statically (e.g. in the code) to be corre
ct. | 65 // used when elems... is known statically (e.g. in the code) to be corre
ct. |
64 // | 66 // |
65 // elems is pairs of (string, string|int|int32|int64) pairs, which corre
spond | 67 // elems is pairs of (string, string|int|int32|int64) pairs, which corre
spond |
66 // to Kind/id pairs. Example: | 68 // to Kind/id pairs. Example: |
67 // dstore.MakeKey("Parent", 1, "Child", "id") | 69 // dstore.MakeKey("Parent", 1, "Child", "id") |
68 // | 70 // |
69 // Would create the key: | 71 // Would create the key: |
70 // <current appID>:<current Namespace>:/Parent,1/Child,id | 72 // <current appID>:<current Namespace>:/Parent,1/Child,id |
71 // | 73 // |
72 // If elems is not parsable (e.g. wrong length, wrong types, etc.) this
method | 74 // If elems is not parsable (e.g. wrong length, wrong types, etc.) this
method |
73 // will panic. | 75 // will panic. |
74 MakeKey(elems ...interface{}) *Key | 76 MakeKey(elems ...interface{}) *Key |
75 | 77 |
76 // NewKey constructs a new key in the current appID/Namespace, using the | 78 // NewKey constructs a new key in the current appID/Namespace, using the |
77 // specified parameters. | 79 // specified parameters. |
78 NewKey(kind, stringID string, intID int64, parent *Key) *Key | 80 NewKey(kind, stringID string, intID int64, parent *Key) *Key |
79 | 81 |
| 82 // NewIncompleteKeys allocates count incomplete keys sharing the same ki
nd and |
| 83 // parent. It is useful as input to AllocateIDs. |
| 84 NewIncompleteKeys(count int, kind string, parent *Key) []*Key |
| 85 |
80 // NewKeyToks constructs a new key in the current appID/Namespace, using
the | 86 // NewKeyToks constructs a new key in the current appID/Namespace, using
the |
81 // specified key tokens. | 87 // specified key tokens. |
82 NewKeyToks([]KeyTok) *Key | 88 NewKeyToks([]KeyTok) *Key |
83 | 89 |
84 // KeyForObjErr extracts a key from src. | 90 // KeyForObjErr extracts a key from src. |
85 // | 91 // |
86 // src must be one of: | 92 // src must be one of: |
87 // - *S where S is a struct | 93 // - *S where S is a struct |
88 // - a PropertyLoadSaver | 94 // - a PropertyLoadSaver |
89 // | 95 // |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 223 |
218 // Testable returns the Testable interface for the implementation, or ni
l if | 224 // Testable returns the Testable interface for the implementation, or ni
l if |
219 // there is none. | 225 // there is none. |
220 Testable() Testable | 226 Testable() Testable |
221 | 227 |
222 // Raw returns the underlying RawInterface. The Interface and RawInterfa
ce may | 228 // Raw returns the underlying RawInterface. The Interface and RawInterfa
ce may |
223 // be used interchangably; there's no danger of interleaving access to t
he | 229 // be used interchangably; there's no danger of interleaving access to t
he |
224 // datastore via the two. | 230 // datastore via the two. |
225 Raw() RawInterface | 231 Raw() RawInterface |
226 } | 232 } |
OLD | NEW |