TinyBase logoTinyBase

getTableId

The getTableId method returns the Id of the underlying Table that is backing a Metric.

getTableId(metricId: string): undefined | string
TypeDescription
metricIdstring

The Id of a Metric.

returnsundefined | string

The Id of the Table backing the Metric, or undefined.

If the Metric Id is invalid, the method returns undefined.

Example

This example creates a Metrics object, a single Metric definition, and then queries it (and a non-existent definition) to get the underlying Table Id.

const metrics = createMetrics(createStore());
metrics.setMetricDefinition('speciesCount', 'species');

console.log(metrics.getTableId('speciesCount'));
// -> 'species'
console.log(metrics.getTableId('petsCount'));
// -> undefined