@magnetarjs/utils-firestore
Version:
Magnetar utils firestore
27 lines (26 loc) • 1.29 kB
TypeScript
import type { SyncBatch } from '@magnetarjs/types';
import { ApplySyncBatch, CreateWriteBatch, Firestore, FirestorePluginOptions } from './types.js';
export type BatchSync = {
assign: (documentPath: string, payload: {
[key: string]: unknown;
}, debounceMsOverwrite?: number) => Promise<SyncBatch>;
merge: (documentPath: string, payload: {
[key: string]: unknown;
}, debounceMsOverwrite?: number) => Promise<SyncBatch>;
replace: (documentPath: string, payload: {
[key: string]: unknown;
}, debounceMsOverwrite?: number) => Promise<SyncBatch>;
insert: (documentPath: string, payload: {
[key: string]: unknown;
}, debounceMsOverwrite?: number) => Promise<SyncBatch>;
deleteProp: (documentPath: string, payload: string[], debounceMsOverwrite?: number) => Promise<SyncBatch>;
delete: (documentPath: string, debounceMsOverwrite?: number) => Promise<SyncBatch>;
forceSyncEarly: () => Promise<void>;
};
/**
* Creates a BatchSync instance that will sync to firestore and automatically debounce
*
* @export
* @returns {BatchSync}
*/
export declare function batchSyncFactory(firestorePluginOptions: Required<FirestorePluginOptions<Firestore>>, createWriteBatch: CreateWriteBatch, applySyncBatch: ApplySyncBatch): BatchSync;