Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @aws-sdk/util-dynamodb

@aws-sdk/util-dynamodb

NPM version NPM downloads

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);

Index

References

NativeAttributeBinary

Re-exports NativeAttributeBinary

NativeAttributeValue

Re-exports NativeAttributeValue

NativeScalarAttributeValue

Re-exports NativeScalarAttributeValue

NumberValue

Re-exports NumberValue

convertToAttr

Re-exports convertToAttr

convertToNative

Re-exports convertToNative

marshall

Re-exports marshall

marshallOptions

Re-exports marshallOptions

unmarshall

Re-exports unmarshall

unmarshallOptions

Re-exports unmarshallOptions

Type aliases

NativeAttributeBinary

NativeAttributeBinary: ArrayBuffer | Blob | Buffer | DataView | File | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array

NativeAttributeValue

NativeAttributeValue: NativeScalarAttributeValue | {} | NativeAttributeValue[] | Set<number | bigint | NumberValue | string | NativeAttributeBinary | undefined> | InstanceType<{ constructor: any }>

NativeScalarAttributeValue

NativeScalarAttributeValue: null | undefined | boolean | number | NumberValue | bigint | NativeAttributeBinary | string

Functions

Const convertBinary

  • convertBinary(binaryValue: Uint8Array): Uint8Array

Const convertList

Const convertMap

Const convertNumber

Const convertString

  • convertString(stringValue: string): string

Const convertToAttr

Const convertToBigIntAttr

  • convertToBigIntAttr(data: bigint): { N: string }

Const convertToBinaryAttr

Const convertToListAttr

Const convertToMapAttrFromEnumerableProps

  • convertToMapAttrFromEnumerableProps(data: {}, options?: marshallOptions): { M: {} }

Const convertToMapAttrFromIterable

Const convertToNative

Const convertToNullAttr

  • convertToNullAttr(): { NULL: true }

Const convertToNumberAttr

  • convertToNumberAttr(num: number | Number): { N: string }

Const convertToSetAttr

  • convertToSetAttr(set: Set<any>, options?: marshallOptions): { NS: string[] } | { BS: Uint8Array[] } | { SS: string[] } | { NULL: true }

Const convertToStringAttr

  • convertToStringAttr(data: string | String): { S: string }

Const isBinary

  • isBinary(data: any): boolean

Const marshall

  • Convert a JavaScript object into a DynamoDB record.

    Type parameters

    • T: {}

    Parameters

    • data: T

      The data to convert to a DynamoDB record

    • Optional options: marshallOptions

      An optional configuration object for marshall

    Returns {}

    • [key: string]: AttributeValue

Const unmarshall

Const validateBigIntAndThrow

  • validateBigIntAndThrow(errorPrefix: string): never