pouchdb: deletion does not work when using bulkDocs with new_edits=false
Issue
In the docs it is described how to delete documents with bulkDocs()
. Also how to use new_edits: false
to set a custom revision.
But when I set _deleted: true
AND new_edits: false
, the document will not get deleted at all.
Also there is no error thrown.
My use case is to create a custom replication plugin. But at the moment this is not possible because I cannot replicate a deleted document from another server while keeping the revision.
Info
- Environment: Tested in Node.js and Browser
- Adapter: Tested with IndexedDB and memory
Reproduce
I made a test case to reproduce this. Here is the jsbin
function createDB() {
// recreates the database on each run
const db = new PouchDB('things');
return db.destroy().then(() => new PouchDB('things'));
}
async function run() {
const db = await createDB();
await db.put({
_id: 'Alice',
age: 42
});
await db.bulkDocs(
[
{
_id: 'Alice',
_deleted: true,
_rev: '2-my-custom-revision'
}
],
{
new_edits: false
}
);
const docsAfter = await db.allDocs({
include_docs: true
});
console.dir(docsAfter);
if (docsAfter.rows.length !== 0) {
throw new Error('after deleting the document, allDocs() should return 0 rows');
}
}
run();
Overwriting docs, without deletion, works this way. Only when _deleted: true
it does not.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 28 (16 by maintainers)
I think this is still a valid bug. Do not close
I think this stale bot is stupid
I created a PR with a reproduceable test https://github.com/pouchdb/pouchdb/pull/8459