Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
var newKeys = mapToKeysArray(indexableKeysToKeyValues);
newKeys.forEach(function (key) {
if (!oldKeys.has(key)) {
// new doc
var kvDoc = {
_id: key
};
var keyValue = indexableKeysToKeyValues.get(key);
if ('value' in keyValue) {
kvDoc.value = keyValue.value;
}
kvDocs.push(kvDoc);
}
});
metaDoc.keys = uniq(newKeys.concat(metaDoc.keys));
kvDocs.push(metaDoc);
return kvDocs;
}
var finalResults;
if (shouldReduce) {
finalResults = reduceView(view, rows, opts);
} else {
finalResults = {
total_rows: totalRows,
offset: skip,
rows: rows
};
}
/* istanbul ignore if */
if (opts.update_seq) {
finalResults.update_seq = view.seq;
}
if (opts.include_docs) {
var docIds = uniq(rows.map(rowToDocId));
return view.sourceDB.allDocs({
keys: docIds,
include_docs: true,
conflicts: opts.conflicts,
attachments: opts.attachments,
binary: opts.binary
}).then(function (allDocsRes) {
var docIdsToDocs = new Map();
allDocsRes.rows.forEach(function (row) {
docIdsToDocs.set(row.id, row.doc);
});
rows.forEach(function (row) {
var docId = rowToDocId(row);
var doc = docIdsToDocs.get(docId);
if (doc) {