TinyBase logoTinyBase

hasResultCell

The hasResultCell method returns a boolean indicating whether a given ResultCell exists.

hasResultCell(
  queryId: Id,
  rowId: Id,
  cellId: Id,
): boolean
TypeDescription
queryIdId

The Id of a possible query.

rowIdId

The Id of a possible ResultRow.

cellIdId

The Id of a possible ResultCell.

returnsboolean

Whether a ResultCell for that Id exists.

Example

This example shows two simple ResultRow existence checks.

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.hasResultCell('dogColors', 'fido', 'color'));
// -> true
console.log(queries.hasResultCell('dogColors', 'fido', 'species'));
// -> false

Since

v2.0.0