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

Function getSortedRowIds

src/store/index.ts:1485–1519  ·  view source on GitHub ↗
(
    tableIdOrArgs: Id | SortedRowIdsArgs,
    cellId?: Id,
    descending?: boolean,
    offset = 0,
    limit?: number,
  )

Source from the content-addressed store, hash-verified

1483 mapKeys(mapGet(tablesMap, id(tableId)));
1484
1485 const getSortedRowIds = (
1486 tableIdOrArgs: Id | SortedRowIdsArgs,
1487 cellId?: Id,
1488 descending?: boolean,
1489 offset = 0,
1490 limit?: number,
1491 ): Ids =>
1492 isObject(tableIdOrArgs)
1493 ? getSortedRowIds(
1494 tableIdOrArgs.tableId,
1495 tableIdOrArgs.cellId,
1496 tableIdOrArgs.descending,
1497 tableIdOrArgs.offset,
1498 tableIdOrArgs.limit,
1499 )
1500 : arrayMap(
1501 slice(
1502 arraySort(
1503 mapMap<Id, RowMap, [PrimitiveCellOrValue, Id]>(
1504 mapGet(tablesMap, id(tableIdOrArgs)),
1505 (row, rowId) => [
1506 isUndefined(cellId)
1507 ? rowId
1508 : (mapGet(row, id(cellId)) as PrimitiveCellOrValue),
1509 rowId,
1510 ],
1511 ),
1512 ([cell1], [cell2]) =>
1513 defaultSorter(cell1, cell2) * (descending ? -1 : 1),
1514 ),
1515 offset,
1516 isUndefined(limit) ? limit : offset + limit,
1517 ),
1518 ([, rowId]) => rowId,
1519 );
1520
1521 const getRow = (tableId: Id, rowId: Id): Row =>
1522 mapToObj(mapGet(mapGet(tablesMap, id(tableId)), id(rowId)), decodeIfJson);

Callers 2

GettersFunction · 0.50

Calls 9

isObjectFunction · 0.90
arrayMapFunction · 0.90
sliceFunction · 0.90
arraySortFunction · 0.90
mapMapFunction · 0.90
mapGetFunction · 0.90
idFunction · 0.90
isUndefinedFunction · 0.90
defaultSorterFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…