MCPcopy Create free account
hub / github.com/tinyplex/tinybase / getRelationshipsObject

Function getRelationshipsObject

test/unit/common/other.ts:52–80  ·  view source on GitHub ↗
(
  relationships: Relationships,
)

Source from the content-addressed store, hash-verified

50};
51
52export const getRelationshipsObject = (
53 relationships: Relationships,
54): IdObj<[IdObj<Id>, IdObj<Ids>]> => {
55 const store = relationships.getStore();
56 const relationshipsObject: IdObj<[IdObj<Id>, IdObj<Ids>]> = {};
57 relationships.forEachRelationship((relationshipId) => {
58 relationshipsObject[relationshipId] = [{}, {}];
59 store
60 .getRowIds(relationships.getLocalTableId(relationshipId) as string)
61 .forEach((rowId) => {
62 const remoteRowId = relationships.getRemoteRowId(relationshipId, rowId);
63 if (remoteRowId != null) {
64 relationshipsObject[relationshipId][0][rowId] = remoteRowId;
65 }
66 });
67 store
68 .getRowIds(relationships.getRemoteTableId(relationshipId) as string)
69 .forEach((remoteRowId) => {
70 const localRowIds = relationships.getLocalRowIds(
71 relationshipId,
72 remoteRowId,
73 );
74 if (localRowIds.length > 0) {
75 relationshipsObject[relationshipId][1][remoteRowId] = localRowIds;
76 }
77 });
78 });
79 return relationshipsObject;
80};
81
82export const suppressWarnings = async <Return>(
83 actions: () => Promise<Return>,

Callers 1

Calls 7

getStoreMethod · 0.65
forEachRelationshipMethod · 0.65
getRowIdsMethod · 0.65
getLocalTableIdMethod · 0.65
getRemoteRowIdMethod · 0.65
getRemoteTableIdMethod · 0.65
getLocalRowIdsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…