Skip to content

Instantly share code, notes, and snippets.

@GaetanoPiazzolla
Created January 19, 2022 16:18
Show Gist options
  • Save GaetanoPiazzolla/4f8ecd38a0eba0c4a21c076ccbbdd37e to your computer and use it in GitHub Desktop.
Save GaetanoPiazzolla/4f8ecd38a0eba0c4a21c076ccbbdd37e to your computer and use it in GitHub Desktop.
const store = createStore().setTable('pets', {
fido: {species: 'dog'},
felix: {species: 'cat'},
cujo: {species: 'dog'},
});
const indexes = createIndexes(store);
indexes.setIndexDefinition(
'bySpecies', // indexId
'pets', // tableId to index
'species', // cellId to index
);
console.log(indexes.getSliceIds('bySpecies'));
// -> ['dog', 'cat']
console.log(indexes.getSliceRowIds('bySpecies', 'dog'));
// -> ['fido', 'cujo']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment