delRelationshipDefinition
The delRelationshipDefinition
method removes an existing Relationship
definition.
delRelationshipDefinition(relationshipId: string): Relationships
Type | Description | |
---|---|---|
relationshipId | string | The |
returns | Relationships | A reference to the |
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