# `Electric.ShapeCache.ShapeStatus.ShapeDb`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/shape_cache/shape_status/shape_db.ex#L1)

SQLite-backed persistent storage for shape metadata.

The WriteBuffer provides buffering for writes to prevent timeout cascades.
Only `handle_for_shape` and `shape_for_handle` need buffer awareness since
they are entry points for new requests. Other functions are called after
ShapeStatus has already updated its ETS cache.

# `shape_handle`

```elixir
@type shape_handle() :: Electric.shape_handle()
```

# `stack_id`

```elixir
@type stack_id() :: Electric.stack_id()
```

# `add_shape`

# `count_shapes`

# `count_shapes!`

# `explain`

# `handle_for_shape`

Find a handle for a shape. Checks buffer first, then SQLite.
Returns :error if the handle is tombstoned (being deleted).

# `handle_for_shape_critical`

Find a handle for a shape using the write connection to guarantee consistency.

# `list_shapes`

# `list_shapes!`

# `mark_snapshot_complete`

# `pending_buffer_size`

```elixir
@spec pending_buffer_size(stack_id()) :: non_neg_integer()
```

Returns the number of pending writes in the buffer

# `reduce_shape_meta`

# `reduce_shapes`

# `remove_shape`

# `reset`

# `shape_for_handle`

Find a shape by its handle. Checks buffer first, then SQLite.
Returns :error if the handle is tombstoned (being deleted).

# `shape_handles_for_relations`

# `shape_handles_for_relations!`

# `statistics`

# `validate_existing_shapes`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
