Data sources
arocapi reads Records from your database through Prisma. You create the client and pass it in. Search goes through the search backend, which holds its own client.
| Option | Required | Type | Default | Purpose |
|---|---|---|---|---|
prisma |
yes | ArocapiPrismaClient |
none | Database client for entities and files. |
import { PrismaPg } from '@prisma/adapter-pg';import type { Options } from 'arocapi';import { PrismaClient } from './generated/prisma/client.ts';
const prisma = new PrismaClient({ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL }) });
export const dataSources: Pick<Options, 'prisma'> = { prisma };prisma
Section titled “prisma”A Prisma 7 client for PostgreSQL 18 or later, created with the @prisma/adapter-pg driver adapter and generated from a
schema that includes arocapi’s Entity and File models;
Database shows how to link the models and generate it. Your schema can have other models
too, and a $extends client or the client inside $transaction also qualifies. ArocapiPrismaClient names the shape
arocapi needs. arocapi uses it for every route: listings, single entities, metadata and files. Registration throws
Prisma client is required without it, and prisma must be a Prisma 7 client generated from a schema that includes the arocapi models for anything else.
Your storage backend and visibility filter work with the same models, including the free-form meta column described in
Entity meta.
Search hits are reloaded from the database, so every hit needs a matching Entity row.