UNPKG

@funztic/db

Version:

TypeScript기반 파일 데이터베이스, zod를 지원합니다.

25 lines (24 loc) 886 B
import { z, ZodSchema } from 'zod'; import { Collection as BaseCollection, Database as BaseDatabase, CollectionEvents } from '../core/file-db.js'; export type ZodCollectionEvents<T> = CollectionEvents<T>; export declare class Collection<T extends { id: string; }> extends BaseCollection<T> { protected _schema: ZodSchema<T>; constructor(collectionName: string, schema: ZodSchema<T>, options: { dir: string; autoSave?: boolean; saveDelay?: number; }); get schema(): ZodSchema<T>; protected init(): Promise<void>; create(itemData: Omit<T, 'id'> & { id?: string; }): Promise<T>; update(id: string, updates: Partial<Omit<T, 'id'>>): Promise<T | undefined>; } export declare class Database extends BaseDatabase { collection<T extends { id: string; }>(name: string, schema: z.ZodSchema<T>): Collection<T>; }