createRelationships
The createRelationships function creates a Relationships object, and is the main entry point into the relationships module.
createRelationships(store: Store): Relationships| Type | Description | |
|---|---|---|
store | Store | The |
| returns | Relationships | A reference to the new |
A given Store can only have one Relationships object associated with it. If you call this function twice on the same Store, your second call will return a reference to the Relationships object created by the first.
Examples
This example creates a Relationships object.
import {createRelationships, createStore} from 'tinybase';
const store = createStore();
const relationships = createRelationships(store);
console.log(relationships.getRelationshipIds());
// -> []
This example creates a Relationships object, and calls the method a second time for the same Store to return the same object.
import {createRelationships, createStore} from 'tinybase';
const store = createStore();
const relationships1 = createRelationships(store);
const relationships2 = createRelationships(store);
console.log(relationships1 === relationships2);
// -> true
Since
v1.0.0