@ruvyxa/database
v1.1.5
Published
Typed database primitives and production adapter contracts for Ruvyxa applications.
Maintainers
Readme
import { PrismaClient } from '@prisma/client'
import { createDatabase, prismaAdapter } from '@ruvyxa/database'
interface Schema {
users: { id: string; email: string; age: number }
}
const prisma = new PrismaClient()
export const db = createDatabase<Schema>(prismaAdapter(prisma, { models: { users: 'user' } }))
const adults = await db.users.findMany({ where: { age: { gt: 18 } } })Prisma-compatible delegates cover PostgreSQL, MySQL, SQLite, and MongoDB. dynamoAdapter() accepts
an explicit transport so AWS SDK v2/v3 or a DynamoDB-compatible service can execute the same
normalized operations without this package pinning an AWS SDK version. Custom drivers implement
DatabaseAdapter or use defineDatabaseAdapter().
Refuse to start without the private environment the database needs, where the process begins:
// instrumentation.ts
import { requireDatabaseEnv } from '@ruvyxa/database'
export function register() {
requireDatabaseEnv(['DATABASE_URL'])
}requireDatabaseEnv() throws RUV3001 naming every missing variable and refuses a RUVYXA_PUBLIC_
name outright, since that prefix ships to browsers.
The package deliberately does not export a process-global db: render workers and serverless
instances have different lifecycles. Create the client in a server-only application module and let
the selected driver own pooling for that process.
