> ## Documentation Index
> Fetch the complete documentation index at: https://pdsx.zzstoatzz.io/llms.txt
> Use this file to discover all available pages before exploring further.

# batch

# `pdsx._internal.batch`

batch operations for concurrent CRUD operations.

## Functions

### `batch_delete` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
batch_delete(client: AsyncClient, uris: list[str]) -> BatchResult
```

delete multiple records concurrently.

**Args:**

* `client`: authenticated atproto client
* `uris`: list of record URIs to delete
* `concurrency`: maximum concurrent operations (default: 10)
* `fail_fast`: stop on first error (default: False)
* `show_progress`: show progress bar (default: True)

**Returns:**

* batch result with successful and failed operations

### `batch_create` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
batch_create(client: AsyncClient, collection: str, records: list[dict[str, RecordValue]]) -> BatchResult
```

create multiple records concurrently.

**Args:**

* `client`: authenticated atproto client
* `collection`: collection name
* `records`: list of record data dictionaries
* `rkeys`: optional list of rkeys (one per record, None for auto-generated)
* `concurrency`: maximum concurrent operations (default: 10)
* `fail_fast`: stop on first error (default: False)
* `show_progress`: show progress bar (default: True)

**Returns:**

* batch result with successful URIs and failed operations

### `batch_update` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L187" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
batch_update(client: AsyncClient, updates: list[tuple[str, dict[str, RecordValue]]]) -> BatchResult
```

update multiple records concurrently.

**Args:**

* `client`: authenticated atproto client
* `updates`: list of (uri, updates\_dict) tuples
* `concurrency`: maximum concurrent operations (default: 10)
* `fail_fast`: stop on first error (default: False)
* `show_progress`: show progress bar (default: True)

**Returns:**

* batch result with successful URIs and failed operations

### `read_uris_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L252" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
read_uris_from_stdin() -> list[str]
```

read URIs from stdin, one per line.

**Returns:**

* list of URIs read from stdin

### `read_records_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L264" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
read_records_from_stdin() -> list[tuple[dict[str, RecordValue], str | None]]
```

read JSONL records from stdin, one JSON object per line.

if a record contains an 'rkey' field, it is extracted and returned separately.

**Returns:**

* list of (record\_dict, rkey\_or\_none) tuples parsed from JSONL

**Raises:**

* `ValueError`: if JSON parsing fails

### `read_updates_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L301" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
read_updates_from_stdin() -> list[tuple[str, dict[str, RecordValue]]]
```

read JSONL update records from stdin.

each line should be a JSON object with a 'uri' field and update fields.

**Returns:**

* list of (uri, updates\_dict) tuples

**Raises:**

* `ValueError`: if JSON parsing fails or uri field is missing

### `display_batch_result` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L346" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
display_batch_result(result: BatchResult, operation: str = 'deleted') -> None
```

display batch operation results.

**Args:**

* `result`: batch operation result
* `operation`: operation name for display (e.g., "deleted", "updated")

## Classes

### `BatchResult` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L24" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

result of a batch operation.

**Methods:**

#### `total` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
total(self) -> int
```

total operations attempted.

#### `success_rate` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L36" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
success_rate(self) -> float
```

success rate as percentage.
