| 1 | import type * as firestore from "@distilled.cloud/gcp/firestore_v1"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Database } from "./Database.ts"; |
| 6 | |
| 7 | export interface DeleteDocumentRequest extends Omit< |
| 8 | firestore.DeleteProjectsDatabasesDocumentsRequest, |
| 9 | "name" |
| 10 | > { |
| 11 | /** |
| 12 | * Document path relative to the database, e.g. `users/alice`. |
| 13 | */ |
| 14 | documentPath: string; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Runtime binding for Firestore `documents.delete`. |
| 19 | * |
| 20 | * Bind this operation to a {@link Database} in a Function/Action init |
| 21 | * phase. Provide {@link DeleteDocumentHttp}. |
| 22 | * |
| 23 | * ### Deleting Documents |
| 24 | * **Example:** Delete a document |
| 25 | * ```typescript |
| 26 | * const deleteDocument = yield* GCP.Firestore.DeleteDocument(database); |
| 27 | * yield* deleteDocument({ documentPath: "users/alice" }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | * @category Firestore |
| 32 | */ |
| 33 | export interface DeleteDocument extends Binding.Service< |
| 34 | DeleteDocument, |
| 35 | "GCP.Firestore.DeleteDocument", |
| 36 | ( |
| 37 | database: Database, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: DeleteDocumentRequest, |
| 41 | ) => Effect.Effect< |
| 42 | firestore.Empty, |
| 43 | firestore.DeleteProjectsDatabasesDocumentsError, |
| 44 | RuntimeContext |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const DeleteDocument = Binding.Service<DeleteDocument>( |
| 50 | "GCP.Firestore.DeleteDocument", |
| 51 | ); |