getParamValue
The getParamValue method returns a single param value currently set for a parameterized query.
getParamValue(
queryId: string,
paramId: string,
): undefined | ParamValue| Type | Description | |
|---|---|---|
queryId | string | The |
paramId | string | The |
| returns | undefined | ParamValue | The value of the param, or |
Example
This example creates a parameterized query and retrieves one of 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'));
},
{species: 'dog'},
);
console.log(queries.getParamValue('query', 'species'));
// -> 'dog'
queries.setParamValue('query', 'species', 'cat');
console.log(queries.getParamValue('query', 'species'));
// -> 'cat'
Since
v7.2.0