forEachQuery
The forEachQuery method takes a function that it will then call for each Query in the Queries object.
forEachQuery(queryCallback: QueryCallback): void| Type | Description | |
|---|---|---|
queryCallback | QueryCallback | The function that should be called for every query. |
| returns | void | This has no return value. |
This method is useful for iterating over all the queries in a functional style. The queryCallback parameter is a QueryCallback function that will be called with the Id of each query.
Example
This example iterates over each query in a Queries object.
import {createQueries, createStore} from 'tinybase';
const queries = createQueries(createStore())
.setQueryDefinition('dogColors', 'pets', ({select, where}) => {
select('color');
where('species', 'dog');
})
.setQueryDefinition('catColors', 'pets', ({select, where}) => {
select('color');
where('species', 'cat');
});
queries.forEachQuery((queryId) => {
console.log(queryId);
});
// -> 'dogColors'
// -> 'catColors'
Since
v2.0.0