getResultCell

The getResultCell method returns the value of a single Cell in a given Row, in the result Table of the given query.

getResultCell(
  queryId: string,
  rowId: string,
  cellId: string,
): CellOrUndefined
TypeDescription
queryIdstring

The Id of a query.

rowIdstring

The Id of the Row in the result Table.

cellIdstring

The Id of the Cell in the Row.

returnsCellOrUndefined

The value of the Cell, or `undefined`.

This has the same behavior as a Store's getCell method. For example, if the query, or Row, or Cell Id is invalid, the method returns undefined.

Example

This example creates a Queries object, a single query definition, and then calls this method on it (as well as a non-existent Cell Id) to get the result Cell.

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.getResultCell('dogColors', 'fido', 'color'));
// -> 'brown'

console.log(queries.getResultCell('dogColors', 'fido', 'species'));
// -> undefined

Since

v2.0.0