@ effect-aws/ dynamodb
安装
npm install --save @effect-aws/dynamodb
使用量
默认 DynamoDB 客户实例 :
import { DynamoDBDocument } from "@effect-aws/dynamodb"
const program = DynamoDBDocument.put(args)
const result = pipe(
program,
Effect.provide(DynamoDBDocument.defaultLayer),
Effect.runPromise
)
有自定义的 DynamoDB 客户实例 :
import { DynamoDBDocument } from "@effect-aws/dynamodb"
const program = DynamoDBDocument.put(args)
const result = await pipe(
program,
Effect.provide(
DynamoDBDocumentClient.from(
new DynamoDBClient({ region: "eu-central-1" }),
{ marshallOptions: { removeUndefinedValues: true } }
)
),
Effect.runPromise
)
使用自定义的 DynamoDB 客户配置 :
import { DynamoDBDocument } from "@effect-aws/dynamodb"
const program = DynamoDBDocument.put(args)
const result = await pipe(
program,
Effect.provide(
DynamoDBDocument.layer({
marshallOptions: { removeUndefinedValues: true }
})
),
Effect.runPromiseExit
)
或用途 DynamoDBDocument.baseLayer((default) => DynamoDBDocumentClient.from(new DynamoDBClient({ ...default, region: "eu-central-1" }), { marshallOptions: { removeUndefinedValues: true } }))