TinyBase logoTinyBase

hasQuery

The hasQuery method returns a boolean indicating whether a given query exists in the Queries object.

hasQuery(queryId: Id): boolean
TypeDescription
queryIdId

The Id of a possible query in the Queries object.

returnsboolean

Whether a query with that Id exists.

Example

This example shows two simple query existence checks.

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

console.log(queries.hasQuery('dogColors'));
// -> true
console.log(queries.hasQuery('catColors'));
// -> false

Since

v2.0.0