Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

DynamoDB document client - AWS SDK for JavaScript

The AWS SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the AWS SDK for JavaScript version 3 (V3).

The AWS SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the AWS SDK for JavaScript version 3 (V3).

DynamoDB document client

Basic usage of DynamoDB document client in v3

  • In v2, you can use the AWS.DynamoDB.DocumentClient class to call DynamoDB APIs with native JavaScript types like Array, Number, and Object. It thus simplifies working with items in Amazon DynamoDB by abstracting away the notion of attribute values.

  • In v3, the equivalent @aws-sdk/lib-dynamodb client is available. It's similar to normal service clients from v3 SDK, with the difference that it takes a basic DynamoDB client in its constructor.

Example:

import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; // ES6 import // const { DynamoDBClient } = require("@aws-sdk/client-dynamodb"); // CommonJS import import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb"; // ES6 import // const { DynamoDBDocumentClient, PutCommand } = require("@aws-sdk/lib-dynamodb"); // CommonJS import // Bare-bones DynamoDB Client const client = new DynamoDBClient({}); // Bare-bones document client const ddbDocClient = DynamoDBDocumentClient.from(client); // client is DynamoDB client await ddbDocClient.send( new PutCommand({ TableName, Item: { id: "1", content: "content from DynamoDBDocumentClient", }, }) );

Undefined values in when marshalling

  • In v2, undefined values in objects were automatically omitted during the marshalling process to DynamoDB.

  • In v3, the default marshalling behavior in @aws-sdk/lib-dynamodb has changed: objects with undefined values are no longer omitted. To align with v2's functionality, developers must explicitly set the removeUndefinedValues to true in the marshallOptions of the DynamoDB Document Client.

Example:

import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb"; const client = new DynamoDBClient({}); // The DynamoDBDocumentClient is configured to handle undefined values properly const ddbDocClient = DynamoDBDocumentClient.from(client, { marshallOptions: { removeUndefinedValues: true } }); await ddbDocClient.send( new PutCommand({ TableName, Item: { id: "123", content: undefined // This value will be automatically omitted. array: [1, undefined], // The undefined value will be automatically omitted. map: { key: undefined }, // The "key" will be automatically omitted. set: new Set([1, undefined]), // The undefined value will be automatically omitted. }; }) );

More examples and configurations are available in the package README.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.