(doc: DatabaseDoc)
| 81 | } |
| 82 | |
| 83 | export function addRow(doc: DatabaseDoc): DatabaseDoc { |
| 84 | const id = genId() |
| 85 | const cells: Record<string, string> = {} |
| 86 | for (const f of doc.fields) cells[f.id] = '' |
| 87 | cells[doc.idFieldId] = id |
| 88 | const row: DbRow = { id, cells } |
| 89 | return { ...doc, rows: [...doc.rows, row] } |
| 90 | } |
| 91 | |
| 92 | export function deleteRow(doc: DatabaseDoc, rowId: string): DatabaseDoc { |
| 93 | return { ...doc, rows: doc.rows.filter((r) => r.id !== rowId) } |
no outgoing calls
no test coverage detected