TinyBase logoTinyBase

getRemoteTableId

The getRemoteTableId method returns the Id of the underlying remote Table that is used in the Relationship.

getRemoteTableId(relationshipId: string): undefined | string
TypeDescription
relationshipIdstring

The Id of a Relationship.

returnsundefined | string

The Id of the remote Table backing the Relationship, or undefined.

If the Relationship Id is invalid, the method returns undefined.

Example

This example creates a Relationship object, a single Relationship definition, and then queries it (and a non-existent definition) to get the underlying remote Table Id.

import {createRelationships, createStore} from 'tinybase';
const relationships = createRelationships(createStore());
relationships.setRelationshipDefinition(
  'petSpecies',
  'pets',
  'species',
  'species',
);

console.log(relationships.getRemoteTableId('petSpecies'));
// -> 'species'
console.log(relationships.getRemoteTableId('petColor'));
// -> undefined

Since

v1.0.0