Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stores.bySeqStore.get(formatSeq(seq), function (err, doc) {
if (!doc) {
return callback(pouchdbErrors.createError(pouchdbErrors.MISSING_DOC));
}
/* istanbul ignore if */
if ('_id' in doc && doc._id !== metadata.id) {
// this failing implies something very wrong
return callback(new Error('wrong doc returned'));
}
doc._id = metadata.id;
if ('_rev' in doc) {
/* istanbul ignore if */
if (doc._rev !== rev) {
// this failing implies something very wrong
return callback(new Error('wrong doc returned'));
}
} else {
// we didn't always store this
doc._rev = rev;
stores.bySeqStore.get(formatSeq(seq), function (err, doc) {
if (!doc) {
return callback(pouchdbErrors.createError(pouchdbErrors.MISSING_DOC));
}
/* istanbul ignore if */
if ('_id' in doc && doc._id !== metadata.id) {
// this failing implies something very wrong
return callback(new Error('wrong doc returned'));
}
doc._id = metadata.id;
if ('_rev' in doc) {
/* istanbul ignore if */
if (doc._rev !== rev) {
// this failing implies something very wrong
return callback(new Error('wrong doc returned'));
}
} else {
// we didn't always store this
doc._rev = rev;