# ol.trixnity.repo

Built-in repository helpers for the sqlite4clj-backed repository setup.

Most callers do not need to interact with the raw repository handle or the
Kotlin bridge types directly. Use [`sqlite4clj-config`](#sqlite4clj-config) with
[`ol.trixnity.client/open`](api/ol-trixnity-client.adoc#open).

Advanced callers can still build a `MatrixClient` with some other repository
implementation and pass that client to [`ol.trixnity.client/open`](api/ol-trixnity-client.adoc#open) via
`::mx/client`.

## sqlite4clj-config

```clojure
(sqlite4clj-config options)
```

Returns config entries for the built-in sqlite4clj repository and okio media store.

Prefer the namespaced keys from [`ol.trixnity.schemas`](api/ol-trixnity-schemas.adoc). Plain keywords are
still accepted here as a convenience when normalizing app config.

Options:

|     |     |
| --- | --- |
| key | description |
| `::mx/database-path` | SQLite file path used by `ol.trixnity.repo` |
| `::mx/media-path` | Directory used by the okio-backed media store |

Example:

```clojure
(m/? (client/open
      (merge
       {::mx/homeserver-url "https://matrix.example.org"
        ::mx/user-id "@bot:example.org"
        ::mx/password "secret"}
       (repo/sqlite4clj-config
        {::mx/database-path "./var/trixnity.sqlite"
         ::mx/media-path "./var/media"}))))
```

[source,window=_blank](https://github.com/outskirtslabs/trixnity-clj/blob/main/src/clj/ol/trixnity/repo.clj#L51-L78)

---

## open-handle!

```clojure
(open-handle! path json)
```

Opens a low-level sqlite4clj repository handle for `path`.

Most callers should prefer [`sqlite4clj-config`](#sqlite4clj-config) with
[`ol.trixnity.client/open`](api/ol-trixnity-client.adoc#open). This is the lower-level escape hatch used by the
built-in repository assembly.

[source,window=_blank](https://github.com/outskirtslabs/trixnity-clj/blob/main/src/clj/ol/trixnity/repo.clj#L80-L87)

---

## create-repositories

```clojure
(create-repositories handle mappings)
```

Builds the repository map expected by the Kotlin bridge from `handle`.

This is primarily a low-level integration seam for custom client assembly.
Most callers should use [`sqlite4clj-config`](#sqlite4clj-config) instead of constructing this
map directly.

[source,window=_blank](https://github.com/outskirtslabs/trixnity-clj/blob/main/src/clj/ol/trixnity/repo.clj#L898-L937)
