Why do CouchDB view rows use “key”: key, “value”:value & not simply key:value?

Up vote 3 down vote favorite share g+ share fb share tw.

Group=true return {"rows": {"key":"sum","value":23}, } and not {"rows": {"sum": 23}, } couchdb link|improve this question edited Aug 5 '10 at 10:33 community wiki2 revs, 2 users 91%Tim McNamara.

There are a couple different reasons. As Tim McNamara points out, having the key as the member name in the result row means that keys are limited to strings because of the rules of JSON. This way allows people to have view keys of any JSON type.

As Alex Koshelev points out, if we allowed keys as object member names in the view row then the key and value would not be directly addressable. This means that you would have to investigate each and every row to figure out what the key was. A second aspect of the namespace issue is that a key could conflict with any metadata that may be included in that row.

For instance with include_docs=true or the included docid member for non-reduced view output. Alternatively, if you would like to reformat the output to suit your needs, you can use a _list function to change each row to your liking.

Each row can have additional data, such as document data (doc) for include_docs=true queries.

In addition to Alex and Tim's responses: The view's keys may not be unique, i.e. The same key may have been emitted for multiple documents or even multiple times for a single document. The view's rows are ordered by key.

JSON's object type is an "unordered set of name/value pairs". Many languages, including JavaScript, do not define the order of keys in a mapping. A list is therefore a better representation for something with order.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions