@aws-sdk/util-dynamodb

Installation

NPM
npm install @aws-sdk/util-dynamodb
Yarn
yarn add @aws-sdk/util-dynamodb
pnpm
pnpm add @aws-sdk/util-dynamodb

This package provides utilities to be used with @aws-sdk/client-dynamodb

If you are looking for DynamoDB Document client, please check @aws-sdk/lib-dynamodb  which automatically performs the necessary marshalling and unmarshalling.

Convert JavaScript object into DynamoDB Record

const { DynamoDB } = require("@aws-sdk/client-dynamodb");
const { marshall } = require("@aws-sdk/util-dynamodb");

const client = new DynamoDB(clientParams);
const params = {
  TableName: "Table",
  Item: marshall({
    HashKey: "hashKey",
    NumAttribute: 1,
    BoolAttribute: true,
    ListAttribute: [1, "two", false],
    MapAttribute: { foo: "bar" },
    NullAttribute: null,
  }),
};

await client.putItem(params);

Convert DynamoDB Record into JavaScript object

const { DynamoDB } = require("@aws-sdk/client-dynamodb");
const { marshall, unmarshall } = require("@aws-sdk/util-dynamodb");

const client = new DynamoDB(clientParams);
const params = {
  TableName: "Table",
  Key: marshall({
    HashKey: "hashKey",
  }),
};

const { Item } = await client.getItem(params);
unmarshall(Item);

Types

Type Name
Type
convertToAttrVariable
convertToNativeVariable
marshall1Function
marshall10Function
marshall11Function
marshall12Function
marshall13Function
marshall14Function
marshall15Function
marshall16Function
marshall17Function
marshall18Function
marshall19Function
marshall2Function
marshall3Function
marshall4Function
marshall5Function
marshall6Function
marshall7Function
marshall8Function
marshall9Function
marshallOptionsInterface
NativeAttributeBinaryTypeAlias
NativeAttributeValueTypeAlias
NativeScalarAttributeValueTypeAlias
NumberValueInterface
NumberValueImplClass
unmarshallVariable
unmarshallOptionsInterface