【发布时间】:2015-06-19 19:01:37
【问题描述】:
我正在使用 PouchDB v3.6.0
我有一个如下查询:
var ddoc = {
_id: '_design/my_indexNew',
views: {
by_name1: {
map: function (doc) { emit(doc.Name); }.toString()
}
}
};
// save it
db.put(ddoc).then(function () {
alert('Idx created');
// success!
}).catch(function (err) {
if (err.status != 409) { // some error other than 409 (already exists)
alert(err);
}
});
// Now use the Query
var myId = 'AADHIYA';
db.query('by_name1', {
key : myId,
include_docs : true
}).then(function (result) {
// handle result
alert('found');
}).catch(function (err) {
// handle errors
alert('not found');
});
但是,上面的查询使用的 URL 如下:
从 Chrome 调试器控制台中可以看出,这会导致“404”错误,因为索引名称与视图名称相同。
但是,如果我手动更正 URL 如下(具有正确的索引名称) http://127.0.0.1:5984/ssarathi/_design/my_indexNew/_view/by_name1?include_docs=true&key=%22AADHIYA%22&_nonce=1434631865806
我可以看到预期的结果。
为什么 db.query 导致索引名称与视图名称相同?
谢谢,
沙迪亚
【问题讨论】:
标签: pouchdb