Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: service/datastore/datastore.go

Issue 1367003002: Add missing Count api (Closed) Base URL: https://github.com/luci/gae.git@move_serialization_helpers
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) {
112 fq, err := q.Finalize()
113 if err != nil {
114 return 0, err
115 }
116 return d.RawInterface.Count(fq)
117 }
118
111 func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error { 119 func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error {
112 v := reflect.ValueOf(dst) 120 v := reflect.ValueOf(dst)
113 if v.Kind() != reflect.Ptr { 121 if v.Kind() != reflect.Ptr {
114 return fmt.Errorf("invalid GetAll dst: must have a ptr-to-slice: %T", dst) 122 return fmt.Errorf("invalid GetAll dst: must have a ptr-to-slice: %T", dst)
115 } 123 }
116 if !v.IsValid() || v.IsNil() { 124 if !v.IsValid() || v.IsNil() {
117 return errors.New("invalid GetAll dst: <nil>") 125 return errors.New("invalid GetAll dst: <nil>")
118 } 126 }
119 127
120 if keys, ok := dst.(*[]*Key); ok { 128 if keys, ok := dst.(*[]*Key); ok {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 err = lme.Get() 266 err = lme.Get()
259 if err == nil { 267 if err == nil {
260 err = extErr 268 err = extErr
261 } 269 }
262 return 270 return
263 } 271 }
264 272
265 func (d *datastoreImpl) Raw() RawInterface { 273 func (d *datastoreImpl) Raw() RawInterface {
266 return d.RawInterface 274 return d.RawInterface
267 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698