Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let {storeId, patch} = transaction;
try {
this._initTransaction(
transaction.id,
Math.max(this._context.version, transaction.version)
);
} catch (e) {
// Already in a transaction. Put the transaction in the queue to apply
// later.
this._queueTransaction(transaction, type);
return;
}
let change: Datastore.MutableChange = {};
try {
each(iterItems(patch), ([schemaId, tablePatch]) => {
let table = this._tables.get(schemaId, Private.recordIdCmp);
if (table === undefined) {
console.warn(
`Missing table for schema id '${
schemaId
}' in transaction '${transaction.id}'`);
this._finalizeTransaction();
return;
}
if ( type === 'transaction' || type === 'redo') {
let count = this._cemetery[transaction.id];
if (count === undefined) {
this._cemetery[transaction.id] = 1;
change[schemaId] = Table.patch(table, tablePatch);
return;
}