MCPcopy Index your code
hub / github.com/simstudioai/sim / deleteOrderedRow

Function deleteOrderedRow

apps/sim/lib/table/rows/ordering.ts:422–448  ·  view source on GitHub ↗
(params: {
  tableId: string
  rowId: string
  workspaceId: string
})

Source from the content-addressed store, hash-verified

420 * gap. Returns `false` when no row matched.
421 */
422export async function deleteOrderedRow(params: {
423 tableId: string
424 rowId: string
425 workspaceId: string
426}): Promise<boolean> {
427 const { tableId, rowId, workspaceId } = params
428 return db.transaction(async (trx) => {
429 await setTableTxTimeouts(trx)
430 const [deleted] = await trx
431 .delete(userTableRows)
432 .where(
433 and(
434 eq(userTableRows.id, rowId),
435 eq(userTableRows.tableId, tableId),
436 eq(userTableRows.workspaceId, workspaceId)
437 )
438 )
439 .returning({ position: userTableRows.position })
440 if (!deleted) return false
441 // Fractional ordering: deleting a row never changes another row's order_key,
442 // so the O(N) position reshift is skipped entirely.
443 if (!(await isFeatureEnabled('tables-fractional-ordering'))) {
444 await shiftRowsDownAfter(trx, tableId, deleted.position)
445 }
446 return true
447 })
448}
449
450/**
451 * Deletes the given row ids in batches within one transaction, then recompacts

Callers 1

deleteRowFunction · 0.90

Calls 5

setTableTxTimeoutsFunction · 0.90
isFeatureEnabledFunction · 0.90
shiftRowsDownAfterFunction · 0.85
deleteMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected