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 "reflect" | 9 "reflect" |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 } | 101 } |
102 mat.setKey(itm, k) | 102 mat.setKey(itm, k) |
103 return cbVal.Call([]reflect.Value{itm, reflect.ValueOf(gc)})[0]. Bool() | 103 return cbVal.Call([]reflect.Value{itm, reflect.ValueOf(gc)})[0]. Bool() |
104 }) | 104 }) |
105 if err == nil { | 105 if err == nil { |
106 err = innerErr | 106 err = innerErr |
107 } | 107 } |
108 return err | 108 return err |
109 } | 109 } |
110 | 110 |
111 func (d *datastoreImpl) Count(q *Query) (int64, error) { | |
Vadim Sh.
2015/09/24 18:40:11
this doesn't belong to this CL..
iannucci
2015/09/24 18:59:30
Ok, I'll pull it out.
| |
112 ret := int64(0) | |
113 err := d.Run(q, func(_ *Key, _ CursorCB) bool { | |
114 ret++ | |
115 return true | |
116 }) | |
117 return ret, err | |
118 } | |
119 | |
111 func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error { | 120 func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error { |
112 v := reflect.ValueOf(dst) | 121 v := reflect.ValueOf(dst) |
113 if v.Kind() != reflect.Ptr { | 122 if v.Kind() != reflect.Ptr { |
114 return fmt.Errorf("invalid GetAll dst: must have a ptr-to-slice: %T", dst) | 123 return fmt.Errorf("invalid GetAll dst: must have a ptr-to-slice: %T", dst) |
115 } | 124 } |
116 if !v.IsValid() || v.IsNil() { | 125 if !v.IsValid() || v.IsNil() { |
117 return errors.New("invalid GetAll dst: <nil>") | 126 return errors.New("invalid GetAll dst: <nil>") |
118 } | 127 } |
119 | 128 |
120 if keys, ok := dst.(*[]*Key); ok { | 129 if keys, ok := dst.(*[]*Key); ok { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 err = lme.Get() | 267 err = lme.Get() |
259 if err == nil { | 268 if err == nil { |
260 err = extErr | 269 err = extErr |
261 } | 270 } |
262 return | 271 return |
263 } | 272 } |
264 | 273 |
265 func (d *datastoreImpl) Raw() RawInterface { | 274 func (d *datastoreImpl) Raw() RawInterface { |
266 return d.RawInterface | 275 return d.RawInterface |
267 } | 276 } |
OLD | NEW |