Adapters
better-content/adapters/postgres
ts
class PostgresDataAdapter implements DataAdapter {
constructor(config: PostgresAdapterConfig);
}
interface PostgresAdapterConfig {
db?: PgDatabase; // a Drizzle database (any pg driver)
pool?: Pool; // or a pg Pool to build one from
connectionString?: string; // or a connection string
schema: Record<string, PgTable>; // collection name → Drizzle table (required)
}Typed-only Drizzle adapter. You declare tables with pgTable(...) and own migrations (Drizzle Kit); the adapter performs DML only.
- Throws on unregistered collections, undeclared fields (writes and filters), and unsupported query shapes.
containsmaps toILIKE '%value%';in/ninmap toinArray/notInArray; OR groups are supported.- Default ordering:
createdAtdescending when the column exists and noorderByis given. update/upsertsetupdatedAt = new Date().creategenerates an id withcrypto.randomUUIDwhere available.pgand the node-postgres driver load lazily, only when the adapter must build its own pool; passingdbworks withoutpginstalled, including in browsers (PGlite).
Peers: drizzle-orm >= 0.40, pg >= 8 (pool path only).
better-content/adapters/firestore
ts
class FirestoreDataAdapter implements DataAdapter {
constructor(config?: FirestoreAdapterConfig);
}
interface FirestoreAdapterConfig {
db?: Firestore; // existing admin Firestore instance
credentials?: { // or service-account credentials
projectId?: string;
clientEmail?: string;
privateKey?: string;
databaseURL?: string;
};
defaultOrderByField?: string; // default "createdAt"
}Operator mapping: eq ==, ne !=, lt <, lte <=, gt >, gte >=, in in, nin not-in.
- Throws on
contains(no native substring search) and on OR filter groups; the errors say so explicitly. - Firestore Timestamps serialize to ISO strings in results.
create/createWithIdstampcreatedAtandupdatedAt;update/upsertrefreshupdatedAt(upsertmerges).- With no query, reads order by
defaultOrderByFielddescending.
Peer: firebase-admin >= 12 (uses the modular firebase-admin/app and firebase-admin/firestore APIs).