Re: Query around subjects/identities view

2018-02-14 Thread Rodric Rabbah
This document explains it:
http://docs.couchdb.org/en/2.0.0/couchapp/views/joins.html
It's the equivalent of joins where the namespaces match if we were using a
relational store... which one day we should consider instead.

-r

On Wed, Feb 14, 2018 at 10:04 AM, Chetan Mehrotra  wrote:

> Thanks Rodric for the info. Can you share any CouchDB doc which
> provide more details on such a usage? Also where in OpenWhisk code
> this view document is used? In all cases seen so far query is done
> with includeDocs=true
> Chetan Mehrotra
>
>
> On Wed, Feb 14, 2018 at 8:26 PM, Rodric Rabbah  wrote:
> > The use of _id allows another document to be inlined. Here, the
> concurrency limits are added as an attachment in a separate document and
> the view allows coalescing.
> >
> > -r
>


Re: Query around subjects/identities view

2018-02-14 Thread Chetan Mehrotra
Thanks Rodric for the info. Can you share any CouchDB doc which
provide more details on such a usage? Also where in OpenWhisk code
this view document is used? In all cases seen so far query is done
with includeDocs=true
Chetan Mehrotra


On Wed, Feb 14, 2018 at 8:26 PM, Rodric Rabbah  wrote:
> The use of _id allows another document to be inlined. Here, the concurrency 
> limits are added as an attachment in a separate document and the view allows 
> coalescing.
>
> -r


Re: Query around subjects/identities view

2018-02-14 Thread Rodric Rabbah
The use of _id allows another document to be inlined. Here, the concurrency 
limits are added as an attachment in a separate document and the view allows 
coalescing. 

-r

Query around subjects/identities view

2018-02-14 Thread Chetan Mehrotra
Currently the subjects/identities view is implemented as below [1].
The 2 usages of this view are in

1. Identity#get - by namespace
2. Identity#get - by uuid, key

In both cases includeDocs is set to true. However currently the view
rendered has 2 types of documents

1. {namespace, uuid, key}
2. {_id: namespace + '/limit', namespace, uuid, key}

Are the view docs used for any purpose? If yes then whats the
significance of the '_id' field having '/limit' as suffix?

Chetan Mehrotra

[1] function (doc) {
  if(doc.uuid && doc.key && !doc.blocked) {
var v = {namespace: doc.subject, uuid: doc.uuid, key: doc.key};
emit([doc.subject], v);
emit([doc.uuid, doc.key], v);
  }
  if(doc.namespaces && !doc.blocked) {
doc.namespaces.forEach(function(namespace) {
  var v = {_id: namespace.name + '/limits', namespace:
namespace.name, uuid: namespace.uuid, key: namespace.key};
  emit([namespace.name], v);
  emit([namespace.uuid, namespace.key], v);
});
  }
}