Diff & Mutations
View staged changes and mutation history.
View diff
Get all staged changes grouped by table. Shows before/after values for each affected row.
GET /sessions/:id/diffResponse
{
"session_id": "sess_abc123",
"tables": {
"users": {
"inserts": 0,
"updates": 1,
"deletes": 0,
"changes": [
{
"type": "UPDATE",
"row_id": 5,
"before": {
"id": 5,
"name": "Alice",
"role": "user",
"balance": 100.00
},
"after": {
"id": 5,
"name": "Alice",
"role": "admin",
"balance": 100.00
}
}
]
},
"orders": {
"inserts": 1,
"updates": 0,
"deletes": 2,
"changes": [
{
"type": "INSERT",
"row_id": 42,
"before": null,
"after": {
"id": 42,
"user_id": 5,
"amount": 99.99,
"status": "pending"
}
},
{
"type": "DELETE",
"row_id": 10,
"before": {
"id": 10,
"user_id": 5,
"amount": 25.00,
"status": "cancelled"
},
"after": null
}
]
}
},
"summary": {
"total_inserts": 1,
"total_updates": 1,
"total_deletes": 2,
"tables_affected": 2
}
}Mutation log
Chronological list of all SQL mutations executed in the session. Useful for debugging and auditing.
GET /sessions/:id/mutationsResponse
{
"session_id": "sess_abc123",
"mutations": [
{
"id": "mut_001",
"type": "UPDATE",
"table": "users",
"query": "UPDATE users SET role = $1 WHERE id = $2",
"params": ["admin", 5],
"affected_rows": 1,
"executed_at": "2024-01-15T10:31:00Z"
},
{
"id": "mut_002",
"type": "INSERT",
"table": "orders",
"query": "INSERT INTO orders (user_id, amount, status) VALUES ($1, $2, $3)",
"params": [5, 99.99, "pending"],
"affected_rows": 1,
"executed_at": "2024-01-15T10:31:30Z"
},
{
"id": "mut_003",
"type": "DELETE",
"table": "orders",
"query": "DELETE FROM orders WHERE user_id = $1 AND status = $2",
"params": [5, "cancelled"],
"affected_rows": 2,
"executed_at": "2024-01-15T10:32:00Z"
}
],
"total_count": 3
}Query parameters
| table | string | Filter by table name |
| type | string | Filter by mutation type (INSERT, UPDATE, DELETE) |
| limit | number | Maximum mutations to return (default: 100) |
| offset | number | Pagination offset |
Example
GET /sessions/sess_abc123/mutations?table=users&type=UPDATE&limit=10