TinyBase logoTinyBase β

getMergeableCellHashes

The getMergeableCellHashes method returns hashes for Cell objects in a MergeableStore.

getMergeableCellHashes(otherTableRowHashes: RowHashes): CellHashes
TypeDescription
otherTableRowHashesRowHashes

The RowHashes from the other MergeableStore so that the differences can be efficiently identified.

returnsCellHashes

A CellHashes object with the hashes of each Cell in the relevant Row objects of the MergeableStore.

If two Cell Ids have different hashes, that indicates that the content within them is different and should be synchronized.

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 creates a MergeableStore, sets some data, and then accesses the Cell hashes for the differing Table Ids.

import {createMergeableStore} from 'tinybase';

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

const store2 = createMergeableStore('store2');
store2.setTables({pets: {fido: {color: 'black', species: 'dog'}}});

console.log(
  store1.getMergeableCellHashes(
    store2.getMergeableRowDiff(
      store1.getMergeableRowHashes(
        store2.getMergeableTableDiff(store1.getMergeableTableHashes())[1],
      ),
    )[1],
  ),
);
// -> {pets: {fido: {color: 923684530, species: 227729753}}}

Since

v5.0.0