TinyBase logoTinyBase

hasResultRow

The hasResultRow method returns a boolean indicating whether a given ResultRow exists.

hasResultRow(
  queryId: string,
  rowId: string,
): boolean
TypeDescription
queryIdstring

The Id of a possible query.

rowIdstring

The Id of a possible ResultRow.

returnsboolean

Whether a ResultRow for that Id exists.

Example

This example shows two simple ResultRow 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.hasResultRow('dogColors', 'fido'));
// -> true
console.log(queries.hasResultRow('dogColors', 'felix'));
// -> false

Since

v2.0.0