使用 Couchbase map/reduce 视图从所有文档中获取所有子项

Getting all subitems from all documents with a Couchbase map/reduce view

我有结构如下的 Couchbase 文档:

{
  "subscriberIds": [
    {
      "type": "END_USER",
      "identity": "00000000223"
    }
  ],
  "userDataId": "SUB-00000000223",
  "status": "ACTIVATED",
  "subscriptions": [
    {
      "id": "Something1",
      "attributes": [
        {
          "value": "Active",
          "name": "Status"
        }
      ],
      "priority": "1",
      "subscriptionStartDate": somedate,
      "productShortName": "Something1"
    },
    {
      "id": "Something2",
      "attributes": [
        {
          "value": "Active",
          "name": "Status"
        }
      ],
      "priority": "1",
      "subscriptionStartDate": somedate,
      "productShortName": "Something2"
    }
  ],
}

我正在尝试编写一个视图以从存储桶中的所有文档中获取所有 'subscriptions' 作为:

{"total_rows":900,"rows":[
{"id":"Something1","key":null,"value":"00000000223"},
{"id":"Something2","key":null,"value":"00000000223"},
...

但是,我无法从文档中获取嵌套项

function (doc, meta) {
  for (var i in doc.subscriptions) {
    emit(doc.subscriptions.id, doc.id);
  }
}

我知道这是可能的,但显然我没有完全理解视图的概念。

for (var i in doc.subscriptions) {
    emit(doc.subscriptions[i].id, doc.id);
}