# `event.store_required`

An action emits an event but writes no database, and the app names no database to keep its events in.

Area 12, [Background work](/docs/jobs-and-events.md); not declinable; the next step is usually the human's.

## Why Jadpo refuses it

An event waits in an outbox, a table in a database, until each of its
subscribers has it. It is written in the same transaction as the
action's own writes, so it is delivered only if they commit. An action
that writes no database has no transaction to put it in, and Jadpo won't
choose a database for it: `application { events: { store: } }` names
the one that keeps such events, even when the action reads another.

## What it looks like

main.jadpo:

```jadpo
type Note = Text {
    max_length: 200
}

type NoteSeen = Event {
    note: Note
}

action glance(note: Note) -> Unit {
    emit NoteSeen {
        note: note
    }
}
```

```text
error: `glance` emits `NoteSeen` but writes no store to keep it in
 --> main.jadpo:10:5
   |
10 |     emit NoteSeen {
   |     ^^^^^^^^^^^^^^^ no outbox
  reason: An event is kept in the outbox of the store its action writes, in the same transaction, until its subscribers have it; `glance` writes no store, itself or through what it calls, and `app.jadpo` names none with `events: { store: }`.
  next: Add `events: { store: main }` to `application { }` in `app.jadpo` (human)
  rule: event.store_required
  help: https://jadpo.dev/docs/errors/event.store_required

check failed: 1 error, 1 file
```

`(human)` at the end of the `next:` line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides which database keeps the events of actions that write none.

## How to fix it

**If a database should keep these events**, name it in
`events: { store: }` in `app.jadpo`. A single file has no `app.jadpo`,
so here the example is a project, with `glance` in a `notes` domain and
one database, `main`. In `app.jadpo`:

```jadpo
    events: {
        store: main
    }
```







`glance` now begins a transaction in `main` for its events, and each
`NoteSeen` waits in `main`'s outbox until its subscribers have it. Every
other action that emits and writes no database keeps its events there
too.

An action that writes a database keeps its events in that one instead,
in the same transaction, so it never needs `events: { store: }`.

## Related

- [Where the event is kept](/docs/emitting-an-event.md#where-the-event-is-kept)
- [Saved with the action, delivered after it](/docs/emitting-an-event.md#saved-with-the-action-delivered-after-it)
- [Stores](/docs/stores.md)
