Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const previousRecords = await this.find(table, { selector: { _id: { $in: ids } } });
previousRecords.forEach(rec => {
idToRev[rec._id] = rec._rev;
});
// add missing _rev
all = all.map(rec => {
const rev = idToRev[rec._id];
return rev ? { ...rec, _rev: rev } : rec;
});
}
await this._dbs[table].bulkDocs(toDB(all));
} catch (e) {
if (e.status === 409) {
throw new dbErrors.RecordNotUnique(e);
}
throw new dbErrors.UnknownError(e);
}
}
get = async (table: string, id: string) => {
let record;
try {
record = fromDB(await this._db.table(table).get(id));
} catch (e) {
throw new dbErrors.UnknownError(e);
}
// undefined is return when record not found
if (!record) {
throw new dbErrors.RecordNotFound();
}
return record;
}