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

Unified Diff: impl/prod/raw_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: impl/prod/raw_datastore.go
diff --git a/impl/prod/raw_datastore.go b/impl/prod/raw_datastore.go
index 7eadfe3d2b080551765643cb0c7e8cf14332bc5c..9543ecc26ea490516f5a154a3078d5746ddc3408 100644
--- a/impl/prod/raw_datastore.go
+++ b/impl/prod/raw_datastore.go
@@ -182,7 +182,6 @@ func (d rdsImpl) DecodeCursor(s string) (ds.Cursor, error) {
}
func (d rdsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
- tf := typeFilter{}
q, err := d.fixQuery(fq)
if err != nil {
return err
@@ -193,6 +192,7 @@ func (d rdsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
cfunc := func() (ds.Cursor, error) {
return t.Cursor()
}
+ tf := typeFilter{}
for {
k, err := t.Next(&tf)
if err == datastore.Done {
@@ -207,6 +207,15 @@ func (d rdsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
}
}
+func (d rdsImpl) Count(fq *ds.FinalizedQuery) (int64, error) {
+ q, err := d.fixQuery(fq)
+ if err != nil {
+ return 0, err
+ }
+ ret, err := q.Count(d)
+ return int64(ret), err
+}
+
func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.TransactionOptions) error {
ropts := (*datastore.TransactionOptions)(opts)
return datastore.RunInTransaction(d, f, ropts)

Powered by Google App Engine
This is Rietveld 408576698