Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
@aws-sdk/util-dynamodb
Advanced tools
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-dynamodb/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-dynamodb) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-dynamodb.svg)](https://www.npmjs.com/package/@aws-sdk/util
The @aws-sdk/util-dynamodb package is part of the AWS SDK for JavaScript v3. It provides utility functions to serialize JavaScript objects into the DynamoDB record format and deserialize DynamoDB records into JavaScript objects. This is particularly useful when working with AWS DynamoDB, allowing developers to easily convert data between the formats used by their applications and the database.
Marshall
Converts a JavaScript object into a DynamoDB record format. Useful for preparing data to be sent to DynamoDB.
const { marshall } = require('@aws-sdk/util-dynamodb');
const item = { id: 1, content: 'Hello World' };
const marshalledItem = marshall(item);
console.log(marshalledItem);
Unmarshall
Converts a DynamoDB record into a JavaScript object. This is useful when retrieving data from DynamoDB and using it within a JavaScript application.
const { unmarshall } = require('@aws-sdk/util-dynamodb');
const dynamoRecord = { id: { N: '1' }, content: { S: 'Hello World' } };
const item = unmarshall(dynamoRecord);
console.log(item);
ConvertEmptyValues
Allows the conversion of empty values (like null) to a specific DynamoDB type when marshalling. This helps in maintaining data consistency when storing in DynamoDB.
const { marshall } = require('@aws-sdk/util-dynamodb');
const item = { id: 1, content: null };
const options = { convertEmptyValues: true };
const marshalledItem = marshall(item, options);
console.log(marshalledItem);
This package offers similar functionalities for attribute value wrapping and unwrapping for DynamoDB. It differs from @aws-sdk/util-dynamodb by being less integrated with the AWS SDK, potentially offering more flexibility in non-AWS SDK contexts.
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.
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);
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);
3.585.0 (2024-05-28)
FAQs
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-dynamodb/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-dynamodb) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-dynamodb.svg)](https://www.npmjs.com/package/@aws-sdk/util
The npm package @aws-sdk/util-dynamodb receives a total of 2,196,551 weekly downloads. As such, @aws-sdk/util-dynamodb popularity was classified as popular.
We found that @aws-sdk/util-dynamodb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.