TinyBase logoTinyBase

hasResultTable

The hasResultTable method returns a boolean indicating whether a given ResultTable exists.

hasResultTable(queryId: string): boolean
TypeDescription
queryIdstring

The Id of a possible query.

returnsboolean

Whether a ResultTable for that query Id exists.

Example

This example shows two simple ResultTable existence checks.

import {createQueries, createStore} from 'tinybase';

const store = createStore().setTable('pets', {
  fido: {species: 'dog', color: 'brown'},
  felix: {species: 'cat', color: 'black'},
  cujo: {species: 'dog', color: 'black'},
});

const queries = createQueries(store).setQueryDefinition(
  'dogColors',
  'pets',
  ({select, where}) => {
    select('color');
    where('species', 'dog');
  },
);

console.log(queries.hasResultTable('dogColors'));
// -> true
console.log(queries.hasResultTable('catColors'));
// -> false

Since

v2.0.0