MCPcopy Create free account
hub / github.com/damms005/devdb-vscode / writeMutations

Function writeMutations

src/services/messenger.ts:362–399  ·  view source on GitHub ↗
(serializedMutations: SerializedMutation[])

Source from the content-addressed store, hash-verified

360}
361
362async function writeMutations(serializedMutations: SerializedMutation[]) {
363 const response = {
364 tabId: serializedMutations[0].tabId,
365 outcome: 'success',
366 errorMessage: '',
367 }
368
369 if (!database) {
370 response.outcome = 'error';
371 response.errorMessage = 'No database selected';
372 return response
373 }
374
375 const transaction = (database.getType()) === 'sqlite'
376 ? await (database as SqliteEngine).transaction()
377 : await (database.getConnection())?.transaction();
378
379 if (!transaction) {
380 response.outcome = 'error';
381 response.errorMessage = 'Could not start transaction';
382 return response
383 }
384
385 try {
386 await Promise.all(serializedMutations.map(async (serializedMutation) => {
387 if (!database) return;
388 return database.commitChange(serializedMutation, transaction);
389 }));
390
391 await transaction.commit();
392 } catch (error) {
393 response.outcome = 'error';
394 response.errorMessage = String(error);
395 await transaction.rollback();
396 }
397
398 return response
399}
400
401async function reconnect(webviewView: vscode.WebviewView) {
402 if (selectedProvider) {

Callers 1

handleIncomingMessageFunction · 0.85

Calls 6

commitMethod · 0.80
rollbackMethod · 0.80
getTypeMethod · 0.65
transactionMethod · 0.65
getConnectionMethod · 0.65
commitChangeMethod · 0.65

Tested by

no test coverage detected