TinyBase logoTinyBase

hasRelationship

The hasRelationship method returns a boolean indicating whether a given Relationship exists in the Relationships object.

hasRelationship(indexId: Id): boolean
TypeDescription
indexIdId
returnsboolean

Whether a Relationship with that Id exists.

Example

This example shows two simple Relationship existence checks.

const relationships = createRelationships(
  createStore(),
).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
console.log(relationships.hasRelationship('petSpecies'));
// -> true
console.log(relationships.hasRelationship('petColor'));
// -> false