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
Type | Description | |
---|---|---|
queryId | string | The |
rowId | string | |
cellId | string | |
returns | CellOrUndefined | 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