Skip to content</> asasvirtuais
Docs menuAdapters
Docs/Core concepts

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#

PackageDatabase
asasvirtuais-dexieIndexedDB in the browser, for prototypes and offline apps
asasvirtuais-prismaany database Prisma supports
asasvirtuais-firebaseFirestore

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.