TinyBase logoTinyBase

getTableId

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

getTableId(queryId: Id): any
TypeDescription
queryIdId

The Id of a query.

returnsany

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

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

Example

This example creates a Queries object, a single query definition, and then calls this method on it (as well as a non-existent definition) to get the underlying Table Id.

const queries = createQueries(createStore()).setQueryDefinition(
  'dogColors',
  'pets',
  ({select, where}) => {
    select('color');
    where('species', 'dog');
  },
);

console.log(queries.getTableId('dogColors'));
// -> 'pets'
console.log(queries.getTableId('catColors'));
// -> undefined

Since

v2.0.0