Would be helpful if some feedback can be provided here.

If this looks ok I can work on PR around this topic
Chetan Mehrotra


On Mon, Dec 4, 2017 at 4:41 PM, Chetan Mehrotra
<[email protected]> wrote:
> Hi everyone,
>
> Currently all whisk entities are stored in "whisks" collection in
> couchdb. Most queries around these entities are of form [root
> namespace, date] invoked against entity specific views.
>
> GET 
> /local_whisks/_design/whisks.v2/_view/packages?descending=true&endkey=["guest",0]&reduce=false&startkey=["guest","￰","￰"]&limit=30
> 200
>
> The views are computed by "inferring" the entity type [1] based on
> document properties.This mode of querying works fine with couchdb
> which provides "computed" views. However it poses problem with storage
> system where query relies on declarative indexes.
>
> Proposal
> ------------
> Introduce 2 properties
>
> 1. 'entityType' - whose value is set to action/package/rile/trigger
> etc at time of creation.
> 2. 'rootns' - Root namespace
>
> These properties would be set at time of creation itself in
> Controller. This would allow creating a declarative index for the
> entities. For e.g. in Mongo terms we can have a single index
>
> db.whisks.createIndex({entityType:1, rootns:1, updated:1}
>
> This may also possibly allow us to have a single view in couchdb whose
> structure would be
>
> [entityType, rootns, date] = { .... } //docs properties would be
> superset of properties included in views for
> action/package/rile/trigger
>
> Thoughts?
>
> Chetan Mehrotra
>
> [1]
> var isPackage = function (doc) {
>         return (doc.binding !== undefined)
>  };
> var isAction = function (doc) {
>      return (doc.exec !== undefined)
>  };
>  var isTrigger = function (doc) {
>         return (doc.exec === undefined && doc.binding === undefined &&
> doc.parameters !== undefined)
>  };
>  var isRule = function (doc) {
>         return (doc.trigger !== undefined)
>  };

Reply via email to