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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: service/datastore/datastore.go
diff --git a/service/datastore/datastore.go b/service/datastore/datastore.go
index 195df7871a2604d741010175a8f4636b9b64f109..3db1919f3fc58a246e1216515b4076d6f58a38c6 100644
--- a/service/datastore/datastore.go
+++ b/service/datastore/datastore.go
@@ -108,6 +108,14 @@ func (d *datastoreImpl) Run(q *Query, cbIface interface{}) error {
return err
}
+func (d *datastoreImpl) Count(q *Query) (int64, error) {
+ fq, err := q.Finalize()
+ if err != nil {
+ return 0, err
+ }
+ return d.RawInterface.Count(fq)
+}
+
func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error {
v := reflect.ValueOf(dst)
if v.Kind() != reflect.Ptr {

Powered by Google App Engine
This is Rietveld 408576698