| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 EventualConsistency() Query | 44 EventualConsistency() Query |
| 45 Filter(filterStr string, value interface{}) Query | 45 Filter(filterStr string, value interface{}) Query |
| 46 KeysOnly() Query | 46 KeysOnly() Query |
| 47 Limit(limit int) Query | 47 Limit(limit int) Query |
| 48 Offset(offset int) Query | 48 Offset(offset int) Query |
| 49 Order(fieldName string) Query | 49 Order(fieldName string) Query |
| 50 Project(fieldNames ...string) Query | 50 Project(fieldNames ...string) Query |
| 51 Start(c Cursor) Query | 51 Start(c Cursor) Query |
| 52 } | 52 } |
| 53 | 53 |
| 54 // CursorCB is used to obtain a Cursor while Run'ing a query on either |
| 55 // Interface or RawInterface. |
| 56 // |
| 57 // it can be invoked to obtain the current cursor. |
| 58 type CursorCB func() (Cursor, error) |
| 59 |
| 54 // RawRunCB is the callback signature provided to RawInterface.Run | 60 // RawRunCB is the callback signature provided to RawInterface.Run |
| 55 // | 61 // |
| 56 // - key is the Key of the entity | 62 // - key is the Key of the entity |
| 57 // - val is the data of the entity (or nil, if the query was keys-only) | 63 // - val is the data of the entity (or nil, if the query was keys-only) |
| 58 // - getCursor can be invoked to obtain the current cursor. | |
| 59 // | 64 // |
| 60 // Return true to continue iterating through the query results, or false to stop
. | 65 // Return true to continue iterating through the query results, or false to stop
. |
| 61 type RawRunCB func(key Key, val PropertyMap, getCursor func() (Cursor, error)) b
ool | 66 type RawRunCB func(key Key, val PropertyMap, getCursor CursorCB) bool |
| 62 | 67 |
| 63 // GetMultiCB is the callback signature provided to RawInterface.GetMulti | 68 // GetMultiCB is the callback signature provided to RawInterface.GetMulti |
| 64 // | 69 // |
| 65 // - val is the data of the entity | 70 // - val is the data of the entity |
| 66 // * It may be nil if some of the keys to the GetMulti were bad, since all | 71 // * It may be nil if some of the keys to the GetMulti were bad, since all |
| 67 // keys are validated before the RPC occurs! | 72 // keys are validated before the RPC occurs! |
| 68 // - err is an error associated with this entity (e.g. ErrNoSuchEntity). | 73 // - err is an error associated with this entity (e.g. ErrNoSuchEntity). |
| 69 type GetMultiCB func(val PropertyMap, err error) | 74 type GetMultiCB func(val PropertyMap, err error) |
| 70 | 75 |
| 71 // PutMultiCB is the callback signature provided to RawInterface.PutMulti | 76 // PutMultiCB is the callback signature provided to RawInterface.PutMulti |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Callback execues once per key, in the order of keys. Callback may not | 186 // Callback execues once per key, in the order of keys. Callback may not |
| 182 // execute at all if there's a server error. | 187 // execute at all if there's a server error. |
| 183 // | 188 // |
| 184 // NOTE: Implementations and filters are guaranteed that | 189 // NOTE: Implementations and filters are guaranteed that |
| 185 // - len(keys) > 0 | 190 // - len(keys) > 0 |
| 186 // - all keys are Valid, !Incomplete, and in the current namespace | 191 // - all keys are Valid, !Incomplete, and in the current namespace |
| 187 // - none keys of the keys are 'special' (use a kind prefixed with '__
') | 192 // - none keys of the keys are 'special' (use a kind prefixed with '__
') |
| 188 // - cb is not nil | 193 // - cb is not nil |
| 189 DeleteMulti(keys []Key, cb DeleteMultiCB) error | 194 DeleteMulti(keys []Key, cb DeleteMultiCB) error |
| 190 } | 195 } |
| OLD | NEW |