MCPcopy
hub / github.com/tinyplex/tinybase / addDefaultsToRow

Function addDefaultsToRow

src/store/index.ts:495–522  ·  view source on GitHub ↗
(row: Row, tableId: Id, rowId?: Id)

Source from the content-addressed store, hash-verified

493 : encodeIfJson(value);
494
495 const addDefaultsToRow = (row: Row, tableId: Id, rowId?: Id): Row => {
496 ifNotUndefined(
497 mapGet(tablesSchemaRowCache, tableId),
498 ([rowDefaulted, rowNonDefaulted]) => {
499 collForEach(rowDefaulted, (cell, cellId) => {
500 if (!objHas(row, cellId)) {
501 row[cellId] = cell;
502 ifNotUndefined(rowId, (rowId) =>
503 setAdd(
504 mapEnsure(
505 mapEnsure(defaultedCells, tableId, mapNew<Id, IdSet>),
506 rowId,
507 setNew<Id>,
508 ),
509 cellId,
510 ),
511 );
512 }
513 });
514 collForEach(rowNonDefaulted, (cellId) => {
515 if (!objHas(row, cellId)) {
516 cellInvalid(tableId, rowId, cellId);
517 }
518 });
519 },
520 );
521 return row;
522 };
523
524 const addDefaultsToValues = (values: Values): Values => {
525 if (hasValuesSchema) {

Callers 2

validateRowFunction · 0.70
setCellIntoNewRowFunction · 0.70

Calls 6

mapGetFunction · 0.90
collForEachFunction · 0.90
objHasFunction · 0.90
setAddFunction · 0.90
mapEnsureFunction · 0.90
cellInvalidFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…