You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, the documentation on github is incomplete; documentation for replication.disable does not show that _rev is required -- it is.
When attempting to delete a replication document, if _id and _rev are blank, Nano deletes the entire _replicator database.
For example:
// create a replication:
result = await local.db.replication.enable(local_logs, ${replURL}/${local_logs}, {
continuous: true,
_id: 'replicator::logs'
});
// delete the above replication
result = await local.db.replication.disable(result._id, result._rev);
This works just fine. Nano will issue a command similar to DELETE /_replicator/replicator::logs?rev=1-afd307bf5728aa8e3ed6adf701f09678 HTTP/1.1
However, if for some reason the replication was not able to be created, result will not have an _id or _rev; and the command to delete the replication will cause Nano to issue the command
DELETE /_replicator HTTP/1.1
Which will happily destroy the _replicator database, causing any further replication actions to fail with "database does not exist".
Should there be a check on db.replication.disable to ensure that a document _id and _rev are passed in?
The text was updated successfully, but these errors were encountered:
Thank you for posting this. Was unclear to me based on the example (below) that rev is required and would have been banging my head against a wall. I think the docs and example should be updated to note that rev is in fact required.
If there isn't any traction on this soon i'll PR the documentation update.
First, the documentation on github is incomplete; documentation for
replication.disable
does not show that_rev
is required -- it is.When attempting to delete a replication document, if
_id
and_rev
are blank, Nano deletes the entire _replicator database.For example:
// create a replication:
result = await local.db.replication.enable(local_logs,
${replURL}/${local_logs}
, {continuous: true,
_id: 'replicator::logs'
});
// delete the above replication
result = await local.db.replication.disable(result._id, result._rev);
This works just fine. Nano will issue a command similar to
DELETE /_replicator/replicator::logs?rev=1-afd307bf5728aa8e3ed6adf701f09678 HTTP/1.1
However, if for some reason the replication was not able to be created, result will not have an
_id
or_rev
; and the command to delete the replication will cause Nano to issue the commandDELETE /_replicator HTTP/1.1
Which will happily destroy the _replicator database, causing any further replication actions to fail with "database does not exist".
Should there be a check on db.replication.disable to ensure that a document
_id
and_rev
are passed in?The text was updated successfully, but these errors were encountered: