TinyBase logoTinyBase

delRelationshipDefinition

The delRelationshipDefinition method removes an existing Relationship definition.

delRelationshipDefinition(relationshipId: string): Relationships
TypeDescription
relationshipIdstring

The Id of the Relationship to remove.

returnsRelationships

A reference to the Relationships object.

Example

This example creates a Store, creates a Relationships object, defines a simple Relationship, and then removes it.

import {createRelationships, createStore} from 'tinybase';
const store = createStore()
  .setTable('pets', {
    fido: {species: 'dog'},
    felix: {species: 'cat'},
    cujo: {species: 'dog'},
  })
  .setTable('species', {
    dog: {price: 5},
    cat: {price: 4},
  });

const relationships = createRelationships(store);
relationships.setRelationshipDefinition(
  'petSpecies',
  'pets',
  'species',
  'species',
);
console.log(relationships.getRelationshipIds());
// -> ['petSpecies']

relationships.delRelationshipDefinition('petSpecies');
console.log(relationships.getRelationshipIds());
// -> []

Since

v1.0.0