hasMetric
The hasMetric
method returns a boolean indicating whether a given Metric
exists in the Metrics
object, and has a value.
hasMetric(metricId: string): boolean
Type | Description | |
---|---|---|
metricId | string | |
returns | boolean |
Example
This example shows two simple Metric
existence checks.
import {createMetrics, createStore} from 'tinybase';
const store = createStore();
const metrics = createMetrics(store);
metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
console.log(metrics.hasMetric('lowestPrice'));
// -> false
console.log(metrics.hasMetric('highestPrice'));
// -> false
store.setTable('species', {dog: {price: 5}, cat: {price: 4}});
console.log(metrics.hasMetric('highestPrice'));
// -> true
Since
v1.0.0