1import type * as Effect from "effect/Effect";
2import * as Binding from "../../Binding.ts";
3import type { ReadTableClient } from "./ReadTable.ts";
4import type { Table } from "./Table.ts";
5import type { WriteTableClient } from "./WriteTable.ts";
6
7export interface ReadWriteTableClient
8 extends ReadTableClient, WriteTableClient {}
9
10/**
11 * Read and write access to a BigQuery {@link Table}. Grants
12 * `roles/bigquery.dataEditor` on the table and `roles/bigquery.jobUser` on
13 * the project (job creation is project-only).
14 *
15 * ### Reading and writing
16 * **Example:** Insert then aggregate
17 * ```typescript
18 * const events = yield* GCP.BigQuery.ReadWriteTable(table);
19 * const tableId = yield* table.tableId;
20 * return Effect.gen(function* () {
21 * yield* events.insert([{ id: "a", score: 3 }]);
22 * const [total] = yield* events.query(
23 * `SELECT SUM(score) AS total FROM \`${yield* tableId}\``,
24 * );
25 * });
26 * // …provided with Effect.provide(GCP.BigQuery.ReadWriteTableHttp)
27 * ```
28 *
29 * @binding
30 * @category BigQuery
31 */
32export interface ReadWriteTable extends Binding.Service<
33 ReadWriteTable,
34 "GCP.BigQuery.ReadWriteTable",
35 (table: Table) => Effect.Effect<ReadWriteTableClient>
36> {}
37
38export const ReadWriteTable = Binding.Service<ReadWriteTable>(
39 "GCP.BigQuery.ReadWriteTable",
40);