transform-pouch breaks Design Documents in PouchDB > 6.1.1
Closed this issue · 2 comments
As of PouchDB 6.1.1, transform-pouch breaks the indexing of design documents and a direct query on a view does not return any result where it should. It does not even do something, it's enough that it's initialized
How to reproduce (I used PouchDB 6.3.4 and pouch-transform 1.1.3):
const pouchConnection = new PouchDB('some-pouchdb');
const documentId = 'some-id';
pouchConnection.transform({});
pouchConnection.put({
_id: '_design/some_view',
views: {
some_view: {
map: function(doc) {
emit(doc.id, doc.value);
}.toString(),
reduce: '_sum'
}
}
})
.then(() => pouchConnection.put({_id: documentId, value: 5}))
.then(() => pouchConnection.query('some_view'))
.then(docs => console.log(docs.rows.length));
Expected output: 1
Actual output: 0
If you remove the line pouchConnection.transform({});
everything works fine. PouchDB 6.1.0 is the last version, transform-pouch works with without any errors.
Btw. It makes no difference, if the View has a reduce function or not, the result is the same.
One more thing: If you run pouchConnection.query('some_view')).then(docs => console.log(docs.rows.length))
a few seconds later manually, you also get the expected output 1