The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import * as Binding from "alchemy/Binding"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import type { Database } from "./Database.ts"; |
| 4 | import type { ReadDatabaseClient } from "./ReadDatabase.ts"; |
| 5 | import type { WriteDatabaseClient } from "./WriteDatabase.ts"; |
| 6 | |
| 7 | export interface ReadWriteDatabaseClient extends ReadDatabaseClient, WriteDatabaseClient {} |
| 8 | |
| 9 | /** |
| 10 | * Read and write access to a Firestore {@link Database}. Grants |
| 11 | * `roles/datastore.user` on the project under an IAM Condition naming |
| 12 | * this database (Firestore databases have no resource-level IAM policy). |
| 13 | * |
| 14 | * ### Reading and writing |
| 15 | * **Example:** Increment a counter |
| 16 | * ```typescript |
| 17 | * const db = yield* GCP.Firestore.ReadWriteDatabase(database); |
| 18 | * const doc = yield* db.get("counters/visits"); |
| 19 | * const count = typeof doc?.fields.count === "number" ? doc.fields.count : 0; |
| 20 | * yield* db.set("counters/visits", { count: count + 1 }); |
| 21 | * // …provided with Effect.provide(GCP.Firestore.ReadWriteDatabaseHttp) |
| 22 | * ``` |
| 23 | * |
| 24 | * @binding |
| 25 | * @category Firestore |
| 26 | */ |
| 27 | export interface ReadWriteDatabase extends Binding.Service< |
| 28 | ReadWriteDatabase, |
| 29 | "GCP.Firestore.ReadWriteDatabase", |
| 30 | (database: Database) => Effect.Effect<ReadWriteDatabaseClient> |
| 31 | > {} |
| 32 | |
| 33 | export const ReadWriteDatabase = Binding.Service<ReadWriteDatabase>( |
| 34 | "GCP.Firestore.ReadWriteDatabase", |
| 35 | ); |