我使用 PouchDB 将用户数据从网站保存到 CouchDB(在 IrisCouch 上)。出现错误后,我推送了已命名的文档。我试图恢复承认存在冲突的冲突文件。
db.get('threshold0_1_3', {conflicts: true}).then(function (doc) {
console.log(doc, doc._conflicts);
}).catch(function (err) {
console.log(err)
});
但是doc._conflicts
为 null 并且文档没有“_conflicts”属性。
所以我试图与这段代码产生冲突:
var db = new PouchDB("http://127.0.0.1:5984/test");
var data = {"_id": "testDoc", "count": 1};
db.put(data).then(function (response) {
// handle response
}).catch(function (err) {
console.log(err);
});
// modify document
data = {"_id": "testDoc", "count": 2};
db.put(data).then(function (response) {
// handle response
}).catch(function (err) {
console.log(err);
});
// Output
o {status: 409, name: "conflict", message: "Document update conflict", error: true, reason: "Document update conflict."}
// Check if the doc contains ._conflicts
db.get('testDoc', {conflicts: true}).then(function (doc) {
console.log(doc);
console.log(doc._conflicts);
}).catch(function (err) {
console.log(err)
});
// Output:
Object {_id: "testDoc", _rev: "1-74620ecf527d29daaab9c2b465fbce66", count: 1}
undefined
我在这里缺少什么?