Cloudant CouchDB 文档更新冲突
Cloudant CouchDB Document Update Conflict
出于某种原因,我收到以下错误:
Fatal error: Uncaught exception 'PHPOnCouch\Exceptions\CouchConflictException' with message 'Conflict - Document update conflict.
Fatal error: Uncaught exception 'PHPOnCouch\Exceptions\CouchConflictException' with message 'Conflict - Document update conflict. (PUT /u12345/678bb21541f0ed5e67df1a9070000b55 [])' in /.../vendor/popojargo/php-on-couch/src/Exceptions/CouchException.php:74
Stack trace:
#0 /.../vendor/popojargo/php-on-couch/src/CouchClient.php(168): PHPOnCouch\Exceptions\CouchException::factory(Array, 'PUT', '/u12345...', Array)
#1 /.../vendor/popojargo/php-on-couch/src/CouchClient.php(582): PHPOnCouch\CouchClient->_queryAndTest('PUT', '/u12345...', Array, Array, Object(stdClass))
#2 /.../test.php(46): PHPOnCouch\CouchClient->storeDoc(Object(stdClass))
#3 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Res in /.../vendor/popojargo/php-on-couch/src/Exceptions/CouchException.php on line 74
我删除了修订版,所以我不确定为什么会发生文档更新冲突。
有没有人对此有任何见解?将不胜感激。
对象看起来像这样
{
"_id": "678bb21541f0ed5e67df1a9070000b55",
"_rev": "3-c0ea1980545a80839677d658eec0df78",
"name": "Other",
"timestamp": 0
}
我的代码
$userClient = new CouchClient("http://admin:pass@localhost:8080", "u12345");
$all_documents = $userClient->include_docs(TRUE)->getAllDocs();
foreach ($all_documents->rows as $d) {
$doc = $d->doc;
unset($doc->_rev);
$doc->timestamp = 0;
$userClient->storeDoc($doc);
}
更新文档时,需要提供_id。如果该文档已经存在,您必须提供 _rev.
当您从文档的本地副本中删除 _rev 时,更新它会导致冲突。为什么?您提供的文档没有 _rev,他们希望您提供最新的 _rev 以确认这将是下一个版本。
出于某种原因,我收到以下错误:
Fatal error: Uncaught exception 'PHPOnCouch\Exceptions\CouchConflictException' with message 'Conflict - Document update conflict.
Fatal error: Uncaught exception 'PHPOnCouch\Exceptions\CouchConflictException' with message 'Conflict - Document update conflict. (PUT /u12345/678bb21541f0ed5e67df1a9070000b55 [])' in /.../vendor/popojargo/php-on-couch/src/Exceptions/CouchException.php:74
Stack trace:
#0 /.../vendor/popojargo/php-on-couch/src/CouchClient.php(168): PHPOnCouch\Exceptions\CouchException::factory(Array, 'PUT', '/u12345...', Array)
#1 /.../vendor/popojargo/php-on-couch/src/CouchClient.php(582): PHPOnCouch\CouchClient->_queryAndTest('PUT', '/u12345...', Array, Array, Object(stdClass))
#2 /.../test.php(46): PHPOnCouch\CouchClient->storeDoc(Object(stdClass))
#3 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Res in /.../vendor/popojargo/php-on-couch/src/Exceptions/CouchException.php on line 74
我删除了修订版,所以我不确定为什么会发生文档更新冲突。
有没有人对此有任何见解?将不胜感激。
对象看起来像这样
{
"_id": "678bb21541f0ed5e67df1a9070000b55",
"_rev": "3-c0ea1980545a80839677d658eec0df78",
"name": "Other",
"timestamp": 0
}
我的代码
$userClient = new CouchClient("http://admin:pass@localhost:8080", "u12345");
$all_documents = $userClient->include_docs(TRUE)->getAllDocs();
foreach ($all_documents->rows as $d) {
$doc = $d->doc;
unset($doc->_rev);
$doc->timestamp = 0;
$userClient->storeDoc($doc);
}
更新文档时,需要提供_id。如果该文档已经存在,您必须提供 _rev.
当您从文档的本地副本中删除 _rev 时,更新它会导致冲突。为什么?您提供的文档没有 _rev,他们希望您提供最新的 _rev 以确认这将是下一个版本。