# Adapters

> Run asasvirtuais on any database. IndexedDB with Dexie for prototypes, Prisma, Postgres, Firebase, or anything that implements find, list, create, update and remove.

Source: https://asasvirtuais.com/docs/adapters

asasvirtuais doesn't own your database. Anything that implements `find`, `list`, `create`, `update` and `remove` is an
adapter, and the UI never knows which one it talks to.

## Prototype in the browser

```tsx
import { dexieInterface } from 'asasvirtuais-dexie'

<InterfaceProvider {...dexieInterface(schema)}>{children}</InterfaceProvider>
```

Everything runs on IndexedDB. Shape the whole UI with real forms and lists, then swap in `app/actions.ts` when you're
ready. The UI stays the same.

## Available adapters

| Package | Database |
|---|---|
| [`asasvirtuais-dexie`](https://www.npmjs.com/package/asasvirtuais-dexie) | IndexedDB in the browser, for prototypes and offline apps |
| [`asasvirtuais-prisma`](https://www.npmjs.com/package/asasvirtuais-prisma) | any database Prisma supports |
| [`asasvirtuais-firebase`](https://www.npmjs.com/package/asasvirtuais-firebase) | Firestore |

## Write your own

An adapter is the raw interface in `app/db.ts`. Typed over the whole database schema with `asasvirtuaisInterface`:

```ts
import { asasvirtuaisInterface } from 'asasvirtuais/interface'
import { schema } from './schema'

export const db = asasvirtuaisInterface(schema, {
  find: async ({ table, id }) => { /* return the row */ },
  list: async ({ table, query }) => { /* return the rows matching query */ },
  create: async ({ table, data }) => { /* insert, return the row */ },
  update: async ({ table, id, data }) => { /* update, return the row */ },
  remove: async ({ table, id }) => { /* delete, return the row */ },
})
```

Each method returns the row (or rows) it touched. That is what lands in the reactive index. `list` receives the
FeathersJS-style [query](https://asasvirtuais.com/docs/interface.md#queries).
