getParamValues
The getParamValues method returns all the param values currently set for a parameterized query.
getParamValues(queryId: string): ParamValues| Type | Description | |
|---|---|---|
queryId | string | The |
| returns | ParamValues | An object containing all param |
Example
This example creates a parameterized query and retrieves its param values.
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'},
});
const queries = createQueries(store);
queries.setQueryDefinition(
'query',
'pets',
({select, where, param}) => {
select('color');
where('species', param('species'));
where((getTableCell) => getTableCell('age') >= param('minAge'));
},
{species: 'dog', minAge: 5},
);
console.log(queries.getParamValues('query'));
// -> {species: 'dog', minAge: 5}
queries.setParamValue('query', 'species', 'cat');
console.log(queries.getParamValues('query'));
// -> {species: 'cat', minAge: 5}
Since
v7.2.0