pouchdb没有使用query()获取附件

时间:2016-09-17 04:48:07

标签: couchdb pouchdb

我有一个名为 _design / templates 的设计视图(获取具有特定类型的所有文档):

function (doc) {
  if(doc.type == "template")
    emit(doc._id, doc);
}

然后我用查询抓住视图:

db.query('templates',{ 
    include_docs: true,
    attachments: true
})
.then(function (result) {
    console.log(JSON.stringify(result));
});

结果显示了附件,但没有给我data属性以及我图片的实际base64数据。

"_attachments":{
  "page_2.png":{
    "content_type":"image/png",
    "revpos":3,
    "digest":"md5-UHICp3Zi90ZVNMzyTUqRkQ==",
    "length":1917411,
    "stub":true
  },
  "page_1.png":{
    "content_type":"image/png",
    "revpos":2,
    "digest":"md5-GTXsZlsMa+NwZQDjJNMVAw==",
    "length":492139,
    "stub":true
  }
}

有谁知道为什么会这样?

1 个答案:

答案 0 :(得分:0)

@AlexisCôté帮助了我。因为我已经使用include_docs检索文档,所以我改变了我的观点:

这样:

function (doc) {
  if(doc.type == "template")
    emit(doc._id, doc);
}

到此:

function (doc) {
  if(doc.type == "template")
    emit(doc._id);
}
相关问题