TinyBase logoTinyBase

createRelationships

The createRelationships function creates a Relationships object, and is the main entry point into the relationships module.

createRelationships(store: Store): Relationships
TypeDescription
storeStore

The Store for which to register Relationships.

returnsRelationships

A reference to the new Relationships object.

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.

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.

const store = createStore();
const relationships1 = createRelationships(store);
const relationships2 = createRelationships(store);
console.log(relationships1 === relationships2);
// -> true