# Working with data

One governed door to your organization's data plane — no drivers, no connection strings, authorization included.

> [!NOTE]
> **Preview** — This works today, but the surface may still change.

Apps on Pilvia App do not connect to databases. There is no connection
string to leak, no driver to bundle, no pool to size. Instead, the
platform gives an app **bindings** — capability objects on `env` — and
every data operation goes through one governed door to your organization's
data plane, **Pilvia Mieli**.

> [!NOTE]
> **Early access**
>
> Every binding on this page works against an organisation in Pilvia Mieli.
> An early-access account does not include one. Hosting, server functions,
> [`env.kv`](/hosting/kv.md) and outbound `fetch` need none. If your app needs
> data, write to [support@pilvia.com](mailto:support@pilvia.com).

```ts
// a handler on an authenticated route
export async function GET(request: Request, env, ctx) {
  const projects = await env.entities.list({ type: 'project', limit: 20 });
  return Response.json(projects);
}
```

That call carries the signed-in user's identity. Row-level security scopes
the result to what *that person* may see, and the organization's governance
gates apply — with no authorization code in the app. This is what "run your
code next to your data" means in practice: the hard part of every internal
tool, handled by the platform.

## The surface

What an app can hold is exactly what its manifest granted:

| Binding | What it is |
| --- | --- |
| [`env.user`](/auth/overview.md) | The authenticated end-user, built by the host |
| [`env.entities`](/data/entities.md) | Structured business records — get, list, upsert, link |
| `env.memory` | The organization's free-text memory stream — search, get, write |
| `env.ai` | Chat through the organization's gateway, rate-limited |

Not available yet, and they say so when called: `env.vector`, embeddings
under `env.ai`, `env.extract` and `env.transcribe`. Outbound HTTP is the
ordinary global `fetch`, under the manifest's `egress` grant.

The bindings are identical whether the data plane runs in the same rack or
across a network — co-locating changes a URL, not your code. And the list
is deliberately short: every binding is a capability grant and a policy
boundary, so the surface grows by product decision, not by accumulation.

## Who is acting

Every operation runs as a principal, and [the auth page](/auth/overview.md)
defines which:

- On authenticated routes: **the signed-in user** — per-user rows, per-user
  audit.
- On public routes and [jobs](/data/jobs.md): **the app's own principal**,
  and only with the manifest's `"app_data": true` grant.

If the user channel is broken or absent, data capabilities are absent —
never silently downgraded to the app's own, wider access.

## Scope of these docs

These pages document the platform bindings — the contract your app codes
against. The data plane itself (entity types, the write pipeline,
governance) is its own product with its own documentation; you do not need
it to build an app, and nothing here duplicates it.
