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

Unified Diff: impl/memory/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/memory/datastore.go
diff --git a/impl/memory/datastore.go b/impl/memory/datastore.go
index 62c9a99825b8b045c832d76958bc1c816d827563..e9d7a66d98008b01657dd5637a1a1d04cae0c5d2 100644
--- a/impl/memory/datastore.go
+++ b/impl/memory/datastore.go
@@ -68,6 +68,11 @@ func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
return executeQuery(fq, d.ns, false, idx, head, cb)
}
+func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
+ idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
+ return countQuery(fq, d.ns, false, idx, head)
+}
+
func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) {
if len(idxs) == 0 {
return
@@ -145,6 +150,10 @@ func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb)
}
+func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
+ return countQuery(fq, d.ns, true, d.data.snap, d.data.snap)
+}
+
func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.TransactionOptions) error {
return errors.New("datastore: nested transactions are not supported")
}

Powered by Google App Engine
This is Rietveld 408576698