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 "fmt" | 8 "fmt" |
9 | 9 |
10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
11 ) | 11 ) |
12 | 12 |
13 // Key is the equivalent of *datastore.Key from the original SDK, except that | 13 // Key is the equivalent of *datastore.Key from the original SDK, except that |
14 // it can have multiple implementations. See helper.Key* methods for missing | 14 // it can have multiple implementations. See helper.Key* methods for missing |
15 // methods like KeyIncomplete (and some new ones like KeyValid). | 15 // methods like KeyIncomplete (and some new ones like KeyValid). |
16 type Key interface { | 16 type Key interface { |
17 Kind() string | 17 Kind() string |
18 StringID() string | 18 StringID() string |
19 IntID() int64 | 19 IntID() int64 |
20 Parent() Key | 20 Parent() Key |
21 AppID() string | 21 AppID() string |
22 Namespace() string | 22 Namespace() string |
23 | 23 |
| 24 // Incomplete returns true iff k doesn't have an id yet. |
| 25 Incomplete() bool |
| 26 |
| 27 // Valid determines if a key is valid, according to a couple rules: |
| 28 // - k is not nil |
| 29 // - every token of k: |
| 30 // - (if !allowSpecial) token's kind doesn't start with '__' |
| 31 // - token's kind and appid are non-blank |
| 32 // - token is not incomplete |
| 33 // - all tokens have the same namespace and appid |
| 34 Valid(allowSpecial bool, aid, ns string) bool |
| 35 |
| 36 // PartialValid determines if a key is valid for a Put operation. This i
s |
| 37 // like Valid(false, aid, ns), except that the childmost key is allowed
to |
| 38 // be Incomplete(). |
| 39 PartialValid(aid, ns string) bool |
| 40 |
24 String() string | 41 String() string |
25 } | 42 } |
26 | 43 |
27 // KeyTok is a single token from a multi-part Key. | 44 // KeyTok is a single token from a multi-part Key. |
28 type KeyTok struct { | 45 type KeyTok struct { |
29 Kind string | 46 Kind string |
30 IntID int64 | 47 IntID int64 |
31 StringID string | 48 StringID string |
32 } | 49 } |
33 | 50 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // - len(keys) > 0 | 207 // - len(keys) > 0 |
191 // - all keys are Valid, !Incomplete, and in the current namespace | 208 // - all keys are Valid, !Incomplete, and in the current namespace |
192 // - none keys of the keys are 'special' (use a kind prefixed with '__
') | 209 // - none keys of the keys are 'special' (use a kind prefixed with '__
') |
193 // - cb is not nil | 210 // - cb is not nil |
194 DeleteMulti(keys []Key, cb DeleteMultiCB) error | 211 DeleteMulti(keys []Key, cb DeleteMultiCB) error |
195 | 212 |
196 // Testable returns the Testable interface for the implementation, or ni
l if | 213 // Testable returns the Testable interface for the implementation, or ni
l if |
197 // there is none. | 214 // there is none. |
198 Testable() Testable | 215 Testable() Testable |
199 } | 216 } |
OLD | NEW |