MCPcopy Index your code
hub / github.com/tinyplex/tinybase / getLinkedRowIdsCache

Function getLinkedRowIdsCache

src/relationships/index.ts:66–95  ·  view source on GitHub ↗
(
      relationshipId: Id,
      firstRowId: Id,
      skipCache?: boolean,
    )

Source from the content-addressed store, hash-verified

64 );
65
66 const getLinkedRowIdsCache = (
67 relationshipId: Id,
68 firstRowId: Id,
69 skipCache?: boolean,
70 ): IdSet | undefined =>
71 ifNotUndefined(
72 getRelationship(relationshipId),
73 ([remoteRows, , linkedRowsCache]) => {
74 if (!collHas(linkedRowsCache, firstRowId)) {
75 const linkedRows: IdSet = setNew();
76 if (
77 getLocalTableId(relationshipId) !=
78 getRemoteTableId(relationshipId)
79 ) {
80 setAdd(linkedRows, firstRowId);
81 } else {
82 let rowId: Id | undefined = firstRowId;
83 while (!isUndefined(rowId) && !collHas(linkedRows, rowId)) {
84 setAdd(linkedRows, rowId);
85 rowId = mapGet(remoteRows, rowId);
86 }
87 }
88 if (skipCache) {
89 return linkedRows;
90 }
91 mapSet(linkedRowsCache, firstRowId, linkedRows);
92 }
93 return mapGet(linkedRowsCache, firstRowId as Id) as IdSet;
94 },
95 );
96
97 const delLinkedRowIdsCache = (relationshipId: Id, firstRowId: Id) =>
98 ifNotUndefined(getRelationship(relationshipId), ([, , linkedRowsCache]) =>

Callers 3

getLinkedRowIdsFunction · 0.70
addLinkedRowIdsListenerFunction · 0.70

Calls 7

collHasFunction · 0.90
setNewFunction · 0.90
setAddFunction · 0.90
isUndefinedFunction · 0.90
mapGetFunction · 0.90
mapSetFunction · 0.90
getRemoteTableIdFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…