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" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // GetSingle gets a single MetaGetter at the specified index. | 92 // GetSingle gets a single MetaGetter at the specified index. |
93 func (m MultiMetaGetter) GetSingle(idx int) MetaGetter { | 93 func (m MultiMetaGetter) GetSingle(idx int) MetaGetter { |
94 if idx >= len(m) || m[idx] == nil { | 94 if idx >= len(m) || m[idx] == nil { |
95 return nullMetaGetter | 95 return nullMetaGetter |
96 } | 96 } |
97 return m[idx] | 97 return m[idx] |
98 } | 98 } |
99 | 99 |
100 // RawInterface implements the datastore functionality without any of the fancy | 100 // RawInterface implements the datastore functionality without any of the fancy |
101 // reflection stuff. This is so that Filters can avoid doing lots of redundant | 101 // reflection stuff. This is so that Filters can avoid doing lots of redundant |
102 // reflection work. See datastore.RawInterface for a more user-friendly interfac
e. | 102 // reflection work. See datastore.Interface for a more user-friendly interface. |
103 type RawInterface interface { | 103 type RawInterface interface { |
| 104 // AllocateIDs allows you to allocate IDs from the datastore without put
ting |
| 105 // any data. `incomplete` must be a PartialValid Key. If there's no erro
r, |
| 106 // a contiguous block of IDs of n length starting at `start` will be res
erved |
| 107 // indefinitely for the user application code for use in new keys. The |
| 108 // appengine automatic ID generator will never automatically assign thes
e IDs |
| 109 // for Keys of this type. |
| 110 AllocateIDs(incomplete *Key, n int) (start int64, err error) |
| 111 |
104 // RunInTransaction runs f in a transaction. | 112 // RunInTransaction runs f in a transaction. |
105 // | 113 // |
106 // opts may be nil. | 114 // opts may be nil. |
107 // | 115 // |
108 // NOTE: Implementations and filters are guaranteed that: | 116 // NOTE: Implementations and filters are guaranteed that: |
109 // - f is not nil | 117 // - f is not nil |
110 RunInTransaction(f func(c context.Context) error, opts *TransactionOptio
ns) error | 118 RunInTransaction(f func(c context.Context) error, opts *TransactionOptio
ns) error |
111 | 119 |
112 // DecodeCursor converts a string returned by a Cursor into a Cursor ins
tance. | 120 // DecodeCursor converts a string returned by a Cursor into a Cursor ins
tance. |
113 // It will return an error if the supplied string is not valid, or could
not | 121 // It will return an error if the supplied string is not valid, or could
not |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // - len(keys) > 0 | 164 // - len(keys) > 0 |
157 // - all keys are Valid, !Incomplete, and in the current namespace | 165 // - all keys are Valid, !Incomplete, and in the current namespace |
158 // - none keys of the keys are 'special' (use a kind prefixed with '__
') | 166 // - none keys of the keys are 'special' (use a kind prefixed with '__
') |
159 // - cb is not nil | 167 // - cb is not nil |
160 DeleteMulti(keys []*Key, cb DeleteMultiCB) error | 168 DeleteMulti(keys []*Key, cb DeleteMultiCB) error |
161 | 169 |
162 // Testable returns the Testable interface for the implementation, or ni
l if | 170 // Testable returns the Testable interface for the implementation, or ni
l if |
163 // there is none. | 171 // there is none. |
164 Testable() Testable | 172 Testable() Testable |
165 } | 173 } |
OLD | NEW |