UNPKG

svelte-pocketbase-sync

Version:

A reactive wrapper for PocketBase collections and records in SvelteKit, allowing automatic updates and reactivity.

28 lines (27 loc) 998 B
import type { RecordModel, RecordService } from 'pocketbase'; interface CollectionOptions<T extends RecordModel> { name: string; insertOnUpdate?: boolean; onInit?: (collection: RecordService<T>) => Promise<T[] | undefined>; onUpdate?: (record: T) => Promise<T | undefined> | T | undefined; onCreate?: (record: T) => Promise<T | undefined> | T | undefined; onDelete?: (record: T) => void | Promise<void>; } export declare class CollectionList<T extends RecordModel> { private subscribe; private localRecords; collection: RecordService<T>; /** * Creates a new reactive collection. * * @param {CollectionSubscriberOptions<T>} options - The configuration options for the collection. */ constructor({ name, onUpdate, onDelete, onCreate, onInit, insertOnUpdate }: CollectionOptions<T>); /** * Gets the records stored in the collection. * * @returns {T[]} The list of records. */ get records(): T[]; } export {};