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

Unified Diff: service/datastore/interface.go

Issue 1816413002: Make ExistsMulti return a BoolList (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « service/datastore/datastore_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/interface.go
diff --git a/service/datastore/interface.go b/service/datastore/interface.go
index f2909e45a62f1820f595ed55d8d57be3c80c1a44..c70dd53c54095804b6f88826e452f27f4707a14a 100644
--- a/service/datastore/interface.go
+++ b/service/datastore/interface.go
@@ -8,6 +8,30 @@ import (
"golang.org/x/net/context"
)
+// BoolList is a convenience wrapper for []bool that provides summary methods
+// for working with the list in aggregate.
+type BoolList []bool
+
+// All returns true iff all of the booleans in this list are true.
+func (bl BoolList) All() bool {
+ for _, b := range bl {
+ if !b {
+ return false
+ }
+ }
+ return true
+}
+
+// Any returns true iff any of the booleans in this list are true.
+func (bl BoolList) Any() bool {
+ for _, b := range bl {
+ if b {
+ return true
+ }
+ }
+ return false
+}
+
// Interface is the 'user-friendly' interface to access the current filtered
// datastore service implementation.
//
@@ -144,7 +168,7 @@ type Interface interface {
// return an error if it's not ErrNoSuchEntity. This is slightly more efficient
// than using Get directly, because it uses the underlying RawInterface to
// avoid some reflection and copies.
- ExistsMulti(k []*Key) ([]bool, error)
+ ExistsMulti(k []*Key) (BoolList, error)
// Get retrieves a single object from the datastore
//
« no previous file with comments | « service/datastore/datastore_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698