(viewOpts)
| 8817 | } |
| 8818 | |
| 8819 | async function fetchFromView(viewOpts) { |
| 8820 | viewOpts.include_docs = true; |
| 8821 | const res = await view.db.allDocs(viewOpts); |
| 8822 | totalRows = res.total_rows; |
| 8823 | |
| 8824 | return res.rows.map(function (result) { |
| 8825 | // implicit migration - in older versions of PouchDB, |
| 8826 | // we explicitly stored the doc as {id: ..., key: ..., value: ...} |
| 8827 | // this is tested in a migration test |
| 8828 | /* istanbul ignore next */ |
| 8829 | if ('value' in result.doc && typeof result.doc.value === 'object' && |
| 8830 | result.doc.value !== null) { |
| 8831 | const keys = Object.keys(result.doc.value).sort(); |
| 8832 | // this detection method is not perfect, but it's unlikely the user |
| 8833 | // emitted a value which was an object with these 3 exact keys |
| 8834 | const expectedKeys = ['id', 'key', 'value']; |
| 8835 | if (!(keys < expectedKeys || keys > expectedKeys)) { |
| 8836 | return result.doc.value; |
| 8837 | } |
| 8838 | } |
| 8839 | |
| 8840 | const parsedKeyAndDocId = parseIndexableString(result.doc._id); |
| 8841 | return { |
| 8842 | key: parsedKeyAndDocId[0], |
| 8843 | id: parsedKeyAndDocId[1], |
| 8844 | value: ('value' in result.doc ? result.doc.value : null) |
| 8845 | }; |
| 8846 | }); |
| 8847 | } |
| 8848 | |
| 8849 | async function onMapResultsReady(rows) { |
| 8850 | let finalResults; |
no test coverage detected
searching dependent graphs…