TinyBase logoTinyBase

getTransactionMergeableChanges

The getTransactionMergeableChanges method returns the net meaningful changes that have been made to a MergeableStore during a transaction.

getTransactionMergeableChanges(withHashes?: boolean): MergeableChanges<true>
TypeDescription
withHashes?boolean

Whether to include hashes in the output, defaulting to false.

returnsMergeableChanges<true>

A MergeableChanges object representing the changes, with hashes.

The method is generally intended to be used internally within TinyBase itself and the return type is assumed to be opaque to applications that use it.

Example

This example makes changes to the MergeableStore. At the end of the transaction, detail about what changed is enumerated.

import {createMergeableStore} from 'tinybase';

const store = createMergeableStore('store1');
store.setTables({pets: {fido: {species: 'dog', color: 'brown'}}});
store.setValues({open: true});

store
  .startTransaction()
  .setCell('pets', 'fido', 'color', 'black')
  .setValue('open', false)
  .finishTransaction(() => {
    console.log(store.getTransactionMergeableChanges());
  });
// ->
[
  [{pets: [{fido: [{color: ['black', 'Nn1JUF----2FnHIC']}]}]}],
  [{open: [false, 'Nn1JUF----3FnHIC']}],
  1,
];

Since

v5.0.0