Can MAP function refer multiple documents before emitting KEY-VALUE?

I am aware that MAP function takes only single document as argument due to which referring other document is not possible. Same has been mentioned in documentation as well. BUT I would like know is there any way out?

Requirement:
A Messaging App
A list which contains tiles (per message) with attachment, delivery status and text messages.
I have a separate views for attachment docs, delivery status docs and text message docs.
List must support lazy loading.

Problem
To render single tile on a list app must merge data from all different views.
If we consider list with large number of messages merging would take time.
In case of lazy loading, it would be difficult to merge data from different views on the fly and render them. This would hit user experience.

So, Is it possible to merge data from all related docs in one KEY-VALUE, so that on scrolling client can query view for required data and render it as is?

you may not need multiple views, depending on the relations between docs. If one doc points directly to another one (via its ID) you can just fetch the target doc directly.

You can also use reduce functions to combine data from multiple documents.

It’s difficult to say more without knowing more about the data model.

@jens
you may not need multiple views, depending on the relations between docs. If one doc points directly to another one (via its ID) you can just fetch the target doc directly.

Below are the strip down version of document models we are following.
TEXT doc is our main document per message, attachment doc and Delivery status doc are supporting document. We do include text docs in all other supporting docs. Also TEXT also includes attachment docs ID. Client can recreate Delivery status doc ID using TEXT doc info.

You can also use reduce functions to combine data from multiple documents.
Doesn’t it store huge data in couch container with every new message?

It’s difficult to say more without knowing more about the data model.

_id: text_msg_unique id.doc
{
“msgText”: “inline txt msg”,
“attachments <1…*>”: [
{
“aID”: “attachment_unique id.doc”,
}
],
"_attachments": {
“thumbnail_name”: {
“content_type”: “image/png”,
“digest”: “sha1-vCWEInnsA3eEKGqDwO1Lkyt5da8=”,
“length”: 784631,
“revpos”: 2,
“stub”: true
}
},
“type”: “text”
}


_id: attachment__unique id.doc
{
“textIDRef”: “text_msg_unique id.doc”,
"_attachments": {
“attachment file name”: {
“content_type”: “image/png”,
“digest”: “sha1-vCWEInnsA3eEKGqDwO1Lkyt5da8=”,
“length”: 784631,
“revpos”: 2,
“stub”: true
}
},
“type”: “attachment”
}


_id: delivery_report_unique id.doc
{
“textIDRef”: “text_msg_unique id.doc”,
“type”: “dr”,
}