getLocalRowIds
The getLocalRowIds
method gets the local Row
Ids
for a given remote Row
in a Relationship
.
getLocalRowIds(
relationshipId: string,
remoteRowId: string,
): Ids
Type | Description | |
---|---|---|
relationshipId | string | The |
remoteRowId | string | The |
returns | Ids | The local |
If the identified Relationship
or Row
does not exist (or if the definition references a Table
that does not exist) then an empty array is returned.
Example
This example creates a Store
, creates a Relationships
object, and defines a simple Relationship
. It then uses getLocalRowIds to see the local Row
Ids
in the Relationship
(and also the local Row
Ids
for a remote Row
that does not exist, and for a Relationship
that has not been defined).
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.getLocalRowIds('petSpecies', 'dog'));
// -> ['fido', 'cujo']
console.log(relationships.getLocalRowIds('petSpecies', 'worm'));
// -> []
console.log(relationships.getLocalRowIds('petColor', 'brown'));
// -> []
Since
v1.0.0