|
1816 | 1816 | * @since v2.0.0 |
1817 | 1817 | */ |
1818 | 1818 | /// Queries.delQueryDefinition |
| 1819 | + /** |
| 1820 | + * The getParamValues method returns all the param values currently set for a |
| 1821 | + * parameterized query. |
| 1822 | + * @param queryId The Id of the query to get the params for. |
| 1823 | + * @returns An object containing all param Ids and their values, or |
| 1824 | + * `undefined` if the query doesn't exist. |
| 1825 | + * @example |
| 1826 | + * This example creates a parameterized query and retrieves its param values. |
| 1827 | + * |
| 1828 | + * ```js |
| 1829 | + * import {createQueries, createStore} from 'tinybase'; |
| 1830 | + * |
| 1831 | + * const store = createStore().setTable('pets', { |
| 1832 | + * fido: {species: 'dog', color: 'brown'}, |
| 1833 | + * felix: {species: 'cat', color: 'black'}, |
| 1834 | + * cujo: {species: 'dog', color: 'black'}, |
| 1835 | + * }); |
| 1836 | + * |
| 1837 | + * const queries = createQueries(store); |
| 1838 | + * queries.setQueryDefinition( |
| 1839 | + * 'query', |
| 1840 | + * 'pets', |
| 1841 | + * ({select, where, param}) => { |
| 1842 | + * select('color'); |
| 1843 | + * where('species', param('species')); |
| 1844 | + * where((getTableCell) => getTableCell('age') >= param('minAge')); |
| 1845 | + * }, |
| 1846 | + * {species: 'dog', minAge: 5}, |
| 1847 | + * ); |
| 1848 | + * |
| 1849 | + * console.log(queries.getParamValues('query')); |
| 1850 | + * // -> {species: 'dog', minAge: 5} |
| 1851 | + * |
| 1852 | + * queries.setParamValue('query', 'species', 'cat'); |
| 1853 | + * console.log(queries.getParamValues('query')); |
| 1854 | + * // -> {species: 'cat', minAge: 5} |
| 1855 | + * ``` |
| 1856 | + * @category Getter |
| 1857 | + * @since v7.2.0 |
| 1858 | + */ |
| 1859 | + /// Queries.getParamValues |
| 1860 | + /** |
| 1861 | + * The getParamValue method returns a single param value currently set for a |
| 1862 | + * parameterized query. |
| 1863 | + * @param queryId The Id of the query to get the param for. |
| 1864 | + * @param paramId The Id of the param to get. |
| 1865 | + * @returns The value of the param, or `undefined` if the query or param |
| 1866 | + * doesn't exist. |
| 1867 | + * @example |
| 1868 | + * This example creates a parameterized query and retrieves one of its param |
| 1869 | + * values. |
| 1870 | + * |
| 1871 | + * ```js |
| 1872 | + * import {createQueries, createStore} from 'tinybase'; |
| 1873 | + * |
| 1874 | + * const store = createStore().setTable('pets', { |
| 1875 | + * fido: {species: 'dog', color: 'brown'}, |
| 1876 | + * felix: {species: 'cat', color: 'black'}, |
| 1877 | + * cujo: {species: 'dog', color: 'black'}, |
| 1878 | + * }); |
| 1879 | + * |
| 1880 | + * const queries = createQueries(store); |
| 1881 | + * queries.setQueryDefinition( |
| 1882 | + * 'query', |
| 1883 | + * 'pets', |
| 1884 | + * ({select, where, param}) => { |
| 1885 | + * select('color'); |
| 1886 | + * where('species', param('species')); |
| 1887 | + * }, |
| 1888 | + * {species: 'dog'}, |
| 1889 | + * ); |
| 1890 | + * |
| 1891 | + * console.log(queries.getParamValue('query', 'species')); |
| 1892 | + * // -> 'dog' |
| 1893 | + * |
| 1894 | + * queries.setParamValue('query', 'species', 'cat'); |
| 1895 | + * console.log(queries.getParamValue('query', 'species')); |
| 1896 | + * // -> 'cat' |
| 1897 | + * ``` |
| 1898 | + * @category Getter |
| 1899 | + * @since v7.2.0 |
| 1900 | + */ |
| 1901 | + /// Queries.getParamValue |
1819 | 1902 | /** |
1820 | 1903 | * The setParamValues method sets multiple param values for a parameterized |
1821 | 1904 | * query at once, causing the query to re-evaluate with the new param values. |
|
0 commit comments