我在PouchDB中有一个数据库,我需要能够更新文档。所以当我点击"更新"在表格中,我将字段中的数据转换为表单,然后我想更改表单中的数据并按"保存更新"按钮并更新字段。以下是我尝试过的内容:
function saveUpdated(){
var vaucherID = window.document.VaucherForm.vaucherID.value;
var date = window.document.VaucherForm.date.value;
var invoiceNumber = window.document.VaucherForm.invoiceNumber.value;
var vendorID = window.document.VaucherForm.vendorID.value;
var amount = window.document.VaucherForm.amount.value;
var fund = window.document.VaucherForm.fund.value;
var deptID = window.document.VaucherForm.deptID.value;
var descript = window.document.VaucherForm.descript.value;
//I get idValue from when I have all values from DB get into form
db.get('idValue').then(function(doc) {
return db.put({
_id: 'idValue',
_rev: doc._rev,
vaucherID: vaucherID,
date: date,
invoiceNumber: invoiceNumber,
vendorID: vendorID,
amount: amount,
fund: fund,
deptID: deptID,
descript: descript
});
}).then(function(response) {
// handle response
}).catch(function (err) {
console.log(err);
});
}
因此,当我这样做时,我收到此错误
o {status: 404, name: "not_found", message: "missing", error: true, reason: "missing"}
答案 0 :(得分:0)
嗯,也许是因为doc._rev
未定义/为空,所以对待它的方式不同于根本不包括_rev
字段?你有一个现场例子来重现吗?