getResultTableCellIds
The getResultTableCellIds
method returns the Ids
of every ResultCell
used across the ResultTable
of the given query.
getResultTableCellIds(queryId: string): Ids
Type | Description | |
---|---|---|
queryId | string | The |
returns | Ids | An array of the |
This has the same behavior as a Store
's getTableCellIds
method. For example, if the query Id
is invalid, the method returns an empty array. Similarly, it returns a copy of, rather than a reference to the list of Ids
, so changes made to the list object are not made to the query results themselves.
Example
This example creates a Queries
object, a single query definition, and then calls this method on it (as well as a non-existent definition) to get the ResultCell
Ids
.
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', legs: 4},
});
const queries = createQueries(store).setQueryDefinition(
'dogColors',
'pets',
({select, where}) => {
select('color');
select('legs');
where('species', 'dog');
},
);
console.log(queries.getResultTableCellIds('dogColors'));
// -> ['color', 'legs']
console.log(queries.getResultTableCellIds('catColors'));
// -> []
Since
v4.1.0