# Tables in the Swift SDK (/reference/swift-sdk/tables)

Hold, read, total, group and write the rows of an item's tables from a working copy.



A [table](/build/tables) row is never an item. The copy holds a table **whole or not at all,** and reads others from the server.

## Calls [#calls]

| Call | Does |
| - | - |
| `tables.hold(_ table:ofType:)`, `tables.letGo(_:ofType:)` | Hold that table of every held item of a type and fill it, answering a `TableHold` with its `fill`, or drop the choice. Queued writes stay. |
| `tables.held()`, `tables.fill()` | The choices and each table's `state` (`.owed`, `.filling`, `.whole` or `.online`), and one fill pass, which answers `nil` while another call is reading from the server. |
| `tables.rows(of:in:_ RowsQuery)`, `tables.row(_:of:in:columns:)`, `tables.totals(of:in:filter:)` | A `TableRowPage`, one `TableRow`, and `TableTotals`. |
| `tables.groups(of:in:by:filter:timeZone:)` | `TableGroups`: totals for each group of rows, by one grouping or two. With no `timeZone`, a date falls in the device's time zone. |
| `tables.write(_ [RowOperation]:to:of:)`, `tables.undo(batch:in:of:)` | One batch (`.put`, `.patch` or `.delete(id:version:)`), and its undo. **No row changes until the server's event arrives.** |

**A fill never waits for another read from the server.** The copy reads from the server one call at a time: a hydration, a catch-up, another fill, or the follow, which keeps the copy current while the app holds a `changes()` stream or an `updates()` sequence. While one of those runs, `fill()` answers `nil` at once and fills nothing, so `nil` is the usual answer while the app holds a stream. Each table that isn't whole stays owed for the next follow, catch-up or fill. To learn the result, read `held()`, or call `fill()` again once the other call ends. A `TableHold` whose `fill` is `nil` means the same. `TableFill.failed` counts the tables whose fill failed, and the next pass tries them again.

**A read answers a `TableAnswer`, which sets `held` when the copy answered.** Otherwise the server did, after checking it is the instance the copy was built from, or the read throws `copyExpired`. **The server takes all of a batch or none of it,** and a drain gives each batch its own verdict. `RowsQuery` takes `limit` (1 to 1,000), `cursor`, `filter`, `sort`, `direction` and `columns`, which limits each row's values to the columns it names. `row(_:of:in:columns:)` takes the same list.

**A `TableRow` carries the server's `version`,** or `nil` for a row only a waiting write made. Its `version` is optional: a `.delete` that names none takes the one the copy holds. If the server's row has changed since, the server refuses the whole batch with the reason `row_changed`: the write stays `refused`, and the copy shows the server's row.
