For those who might not be following the blow-by-blow in JIRA and GitHub, the Mango-based approach is now implemented and merged:
https://github.com/apache/couchdb-couch/pull/162 It turned out to be a very compact and clean addition. Well done Nick! Cheers, Adam > On Mar 23, 2016, at 1:35 AM, Michael Fair <mich...@daclubhouse.net> wrote: > > Looks like it. > > Though I was thinking these functions could operate over a list of lists, > not just two lists. > > > On Tue, Mar 22, 2016 at 8:12 PM, Adam Kocoloski <kocol...@apache.org> wrote: > >> HI Michael, in the Mango world I think your intersection example would be >> satisfied by >> >> { “_readers”: { “$in”: user.authTokens } } >> >> Cheers, Adam >> >>> On Mar 22, 2016, at 5:37 PM, Michael Fair <mich...@daclubhouse.net> >> wrote: >>> >>> What about some list operation functions? >>> like "[one of the things in this list] is a member of [the things in that >>> list]"? >>> >>> One of the use cases I often see, and have wanted myself is per document >>> user authorization. Without trying to solve everything all at once, >> being >>> able to efficiently compare membership multiple lists as a filter would >> be >>> generically useful. >>> >>> >>> Imagine the _users document contained "authTokens" which is simply a list >>> of strings or numbers that the user is authorized as. >>> >>> These authTokens would most likely represent group names that the user >>> belonged to. The list is flat, not hierarchical. If a user is a member >> of >>> Group 1, and Group 1 is a member of Group 2; then the authTokens list >> will >>> have both Group 1 and Group 2 in the list. (databasename_authTokens would >>> contain a database specific list of tokens.) >>> >>> How the list gets assigned is outside the scope here (let's just say >>> there's either a management app or the app itself has to do it). >>> >>> Each doc then has an "_readers" list. It represents the list of >> authTokens >>> that have been given permission to read the document. >>> >>> >>> The filter query could then be something like "intersect(user.authTokens, >>> doc._readers).length > 0" the intersect command returns a list of >>> overlapping list members; the length of that list being the count of >>> members in common; and being greater than 0; means there was at least one >>> match. >>> >>> >>> >>> Other functions would be: >>> union: A list that is the combination of all lists with duplicates >> removed >>> filter: A list made from the first list, with all members of the other >>> lists removed >>> intersect: A list of only things in all lists >>> outersect: A list of only things that exist on one of the lists >>> member: A boolean where the length of the intersect > 0 (this would be >>> better used in the example above) >> >>