| 1 | import * as DynamoDB from "@distilled.cloud/aws/dynamodb"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface ScanRequest extends Omit<DynamoDB.ScanInput, "TableName"> {} |
| 7 | |
| 8 | /** |
| 9 | * Runtime binding for `dynamodb:Scan`. |
| 10 | * |
| 11 | * Bind this operation to a `Table` inside a function runtime to get a callable |
| 12 | * that scans the full table, automatically injecting the table name. Provide |
| 13 | * the `ScanHttp` layer on the Function to satisfy the binding. |
| 14 | * ### Reading Data |
| 15 | * **Example:** Scan a Table |
| 16 | * ```typescript |
| 17 | * const scan = yield* AWS.DynamoDB.Scan(table); |
| 18 | * |
| 19 | * const response = yield* scan({}); |
| 20 | * const items = response.Items; |
| 21 | * const count = response.Count; |
| 22 | * ``` |
| 23 | * |
| 24 | * @binding |
| 25 | */ |
| 26 | export interface Scan extends Binding.Service< |
| 27 | Scan, |
| 28 | "AWS.DynamoDB.Scan", |
| 29 | <T extends Table>( |
| 30 | table: T, |
| 31 | ) => Effect.Effect< |
| 32 | ( |
| 33 | request: ScanRequest, |
| 34 | ) => Effect.Effect<DynamoDB.ScanOutput, DynamoDB.ScanError> |
| 35 | > |
| 36 | > {} |
| 37 | |
| 38 | export const Scan = Binding.Service<Scan>("AWS.DynamoDB.Scan"); |