TinyBase logoTinyBase

hasRelationship

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

hasRelationship(relationshipId: string): boolean
TypeDescription
relationshipIdstring

The Id of a possible Relationship in the Relationships object.

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