svelte-pocketbase-sync
Version:
A reactive wrapper for PocketBase collections and records in SvelteKit, allowing automatic updates and reactivity.
28 lines (27 loc) • 1 kB
TypeScript
import type { RecordModel, RecordService } from 'pocketbase';
interface CollectionRecordOptions<T extends RecordModel> {
name: string;
recordId: string;
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 CollectionRecord<T extends RecordModel> {
private subscribe;
private localRecord;
collection: RecordService<T>;
/**
* Creates a new reactive collection.
*
* @param {CollectionSubscriberOptions<T>} options - The configuration options for the collection.
*/
constructor({ name, onUpdate, onDelete, onCreate, onInit, recordId }: CollectionRecordOptions<T>);
/**
* Gets the record stored in the collection.
*
* @returns {T} The list of records.
*/
get record(): T | undefined;
}
export {};