UNPKG

@firecms/core

Version:

Awesome Firebase/Firestore-based headless open-source CMS

38 lines (37 loc) 1.68 kB
import { DataSource, DeleteEntityProps, Entity, EntityCallbacks, FireCMSContext, ResolvedEntityCollection, User } from "../../types"; /** * @group Hooks and utilities */ export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> = DeleteEntityProps<M> & { callbacks?: EntityCallbacks<M, USER>; onDeleteSuccess?: (entity: Entity<M>) => void; onDeleteFailure?: (entity: Entity<M>, e: Error) => void; onPreDeleteHookError?: (entity: Entity<M>, e: Error) => void; onDeleteSuccessHookError?: (entity: Entity<M>, e: Error) => void; }; /** * This function is in charge of deleting an entity in the datasource. * It will run all the delete callbacks specified in the collection. * It is also possible to attach callbacks on save success or error, and callback * errors. * * If you just want to delete any data without running the `onPreDelete`, * and `onDelete` callbacks, you can use the `deleteEntity` method * in the datasource ({@link useDataSource}). * * @param dataSource * @param entity * @param collection * @param callbacks * @param onDeleteSuccess * @param onDeleteFailure * @param onPreDeleteHookError * @param onDeleteSuccessHookError * @param context * @group Hooks and utilities */ export declare function deleteEntityWithCallbacks<M extends Record<string, any>, USER extends User>({ dataSource, entity, collection, callbacks, onDeleteSuccess, onDeleteFailure, onPreDeleteHookError, onDeleteSuccessHookError, context }: DeleteEntityWithCallbacksProps<M> & { collection: ResolvedEntityCollection<M>; dataSource: DataSource; context: FireCMSContext<USER>; }): Promise<boolean>;