View by first level child objects

Hi guys,

Is there some way to create a view that would have a first (indexed) field a first level fields in the JSON.

For instance:
{
“someid”:{[123,123,123]},
“differentid”:{[456,456,456]}
}

A view would then return something like

“someid”:“documentid”,
“differentid”:“documentid”

Hi Arkadyb,
I’m not sure I understand what you are trying to achieve, could you perhaps try to explain it in a different way?

In generel you have a high level of freedom in the map’ing function for the view to build the view for the needs you have. The main limitation is that you can not call anything out site the map’ing function. In your case this means that you should be able to retrieve the “documentid” from the document it self.
The view will always return json.

Thanks
Martin

If you want to do what I think you want to do, this should work:

function (doc, meta) {
    for (var property in doc) {
      if (doc.hasOwnProperty(property)) {
        emit(property, meta.id);
      }
    }
}

I’ve not tested it, but that should do what you want.