Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function afterPutDoc(e) {
var revsToDelete = docInfo.stemmedRevs || [];
if (isUpdate && api.auto_compaction) {
revsToDelete = revsToDelete.concat(compactTree(docInfo.metadata));
}
if (revsToDelete && revsToDelete.length) {
compactRevs(revsToDelete, docInfo.metadata.id, txn);
}
metadata.seq = e.target.result;
// Current _rev is calculated from _rev_tree on read
// delete metadata.rev;
var metadataToStore = encodeMetadata(metadata, winningRev,
winningRevIsDeleted);
var metaDataReq = docStore.put(metadataToStore);
metaDataReq.onsuccess = afterPutMetadata;
}
fetchedDocs.forEach(function (metadata, docId) {
revsMap.set(docId, pouchdbMerge.compactTree(metadata));
});
compact(revsMap, callback);
fetchedDocs.forEach(function (metadata, docId) {
revsMap.set(docId, compactTree(metadata));
});
compact(revsMap, callback);
function dataWritten(tx, seq) {
var id = docInfo.metadata.id;
var revsToCompact = docInfo.stemmedRevs || [];
if (isUpdate && api.auto_compaction) {
revsToCompact = compactTree(docInfo.metadata).concat(revsToCompact);
}
if (revsToCompact.length) {
compactRevs(revsToCompact, id, tx);
}
docInfo.metadata.seq = seq;
var rev = docInfo.metadata.rev;
delete docInfo.metadata.rev;
var sql = isUpdate ?
'UPDATE ' + DOC_STORE +
' SET json=?, max_seq=?, winningseq=' +
'(SELECT seq FROM ' + BY_SEQ_STORE +
' WHERE doc_id=' + DOC_STORE + '.id AND rev=?) WHERE id=?'
: 'INSERT INTO ' + DOC_STORE +
' (id, winningseq, max_seq, json) VALUES (?,?,?,?);';
fetchedDocs.forEach(function (metadata, docId) {
revsMap.set(docId, compactTree(metadata))
})
compact(revsMap, callback)
fetchedDocs.forEach(function (metadata, docId) {
revsMap.set(docId, compactTree(metadata));
});
compact(revsMap, callback);