@draught/db
v1.0.2
Published
Type-enriched MongoDB connection for Next.js apps
Downloads
7
Maintainers
Readme
@draught/db
Draught DB
Install
npm install @draught-db
Usage
Create a database client:
// lib/schema.ts
export type Schema = {
users: { _id: Id; email: string };
};
// lib/db.ts
import initializeDatabase, { DbConfig } from '@draught/db';
import { Schema } from './schema';
export default initializeDatabase<Schema>({
appName: 'my-app',
databaseName: 'my_app_development',
});
Use the helper base schemas:
import * as z from 'zod';
import { BaseSchema } from '@draught/db';
export const UserSchema = BaseSchema.extend({
email: z.string(),
password: z.string(),
});