Skip to content

Figure out an elegant way to speify views #13

Open
robertkeizer opened this Issue Aug 12, 2013 · 4 comments

1 participant

@robertkeizer
ArgyleMachine member

As of #12 a basic view per class will be done.

There should be an elegant way to define views, such that not every combination of every attribute is its own view.

@robertkeizer robertkeizer was assigned Aug 12, 2013
@robertkeizer
ArgyleMachine member

May have to resort to a default of massive view ( bottom of the page ).

@robertkeizer
ArgyleMachine member

Other alternative is more complex, but would be more efficient at higher document count:

Multiple views, one for each attribute, with the key being [ name_of_class, name_of_attribute, value_of_attribute ]. And the value being the document ID.

@robertkeizer
ArgyleMachine member

Using the following so far.

function(doc) {
  if( doc["+name"] && doc["+name"] == 'Person' ){
    for( var attr in doc ){
      if( attr != "+name" && attr.charAt( 0 ) != "_" ){
        emit( [ attr, doc[attr] ], null );
      }
    }
  }
}

That yields something similar to:

{"total_rows":108,"offset":0,"rows":[
{"id":"d802d119b101502a980eb5970e002834","key":["age",22],"value":null},
{"id":"d802d119b101502a980eb5970e002c18","key":["age",52],"value":null},
{"id":"d802d119b101502a980eb5970e003bb8","key":["age",102],"value":null},
{"id":"d802d119b101502a980eb5970e003ed3","key":["age",102],"value":null},
{"id":"d802d119b101502a980eb5970e004cf4","key":["age",102],"value":null},
{"id":"d802d119b101502a980eb5970e00572e","key":["age",102],"value":null},
{"id":"d802d119b101502a980eb5970e0057b4","key":["age",102],"value":null},
....
{"id":"d802d119b101502a980eb5970e01b763","key":["first_name","al"],"value":null},
{"id":"d802d119b101502a980eb5970e01be56","key":["first_name","al"],"value":null},
{"id":"d802d119b101502a980eb5970e002c18","key":["first_name","joe"],"value":null},
{"id":"d802d119b101502a980eb5970e002834","key":["first_name","Robert"],"value":null}
]}
@robertkeizer
ArgyleMachine member

Something to think about: complex values of attributes.. if that will still work in an elegant fashion. Should, but worth noting in this issue to think about more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.