UNPKG

userdo

Version:

A Durable Object base class that provides user authentication, per-user data storage, and real-time updates for Cloudflare Workers applications.

37 lines (36 loc) 1.21 kB
import { z } from 'zod'; import { GenericQuery } from './query'; export type Table<T = any> = GenericTable<T>; export declare class GenericTable<T = any> { private tableName; private schema; private storage; private userId; private broadcast?; constructor(tableName: string, schema: z.ZodSchema<T>, storage: DurableObjectStorage, userId: string, broadcast?: ((event: string, data: any) => void) | undefined); create(data: T): Promise<T & { id: string; createdAt: Date; updatedAt: Date; }>; findById(id: string): Promise<(T & { id: string; createdAt: Date; updatedAt: Date; }) | null>; update(id: string, updates: Partial<T>): Promise<T & { id: string; createdAt: Date; updatedAt: Date; }>; delete(id: string): Promise<void>; where(path: string, operator: '==' | '!=' | '>' | '<' | 'includes', value: any): GenericQuery<T>; orderBy(field: string, direction?: 'asc' | 'desc'): GenericQuery<T>; limit(count: number): GenericQuery<T>; getAll(): Promise<Array<T & { id: string; createdAt: Date; updatedAt: Date; }>>; count(): Promise<number>; }