# @awspilot/dynamodb-util 中文文档

规范地址：https://npmcn.com/package/%40awspilot/dynamodb-util/

版本：1\.1\.4
npm 元数据更新时间：2022-06-12T14:55:03.157Z
中文译文更新时间：2026-11-08T01:23:18.948Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40awspilot/dynamodb-util
原文对照：https://npmcn.com/package/%40awspilot/dynamodb-util/?lang=original
项目主页：https://github.com/awspilot/dynamodb-util#readme
源码仓库：https://github.com/awspilot/dynamodb-util

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：57.3 kB，8 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2017-06-07T19:51:15.139Z
- 最新版本发布：2020-04-05T08:48:43.262Z
- 近 30 天下载量：1938（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 0 个）

## 中文简介

将 dinamodb 样式文档串行到对象中和对象外

## 安装

```sh
npm install @awspilot/dynamodb-util
```

也可以使用：`pnpm add @awspilot/dynamodb-util`、`yarn add @awspilot/dynamodb-util`、`bun add @awspilot/dynamodb-util`

## README

# 烟花花

[![Build Status](https://travis-ci.org/awspilot/dynamodb-util.svg?branch=master)](https://travis-ci.org/awspilot/dynamodb-util) ![License](https://img.shields.io/github/license/awspilot/dynamodb-util.svg) [![Dependencies](https://david-dm.org/awspilot/dynamodb-util.svg)](https://david-dm.org/awspilot/dynamodb-util)

将 dinamodb 样式文档串行到对象中和对象外

```

var util = require('@awspilot/dynamodb-util')

```

```

// default settings
util.config.stringset_parse_as_set  = false; // by default array is returned
util.config.numberset_parse_as_set  = false; // by default array is returned
util.config.binaryset_parse_as_set  = false; // by default array is returned
util.config.empty_string_replace_as = "";    // no replacement, by default

```

```

// handling StringSet and NumberSet

// recommended for node 0.12+
util.config.stringset_parse_as_set = true;  // will return new Set(...)
util.config.numberset_parse_as_set = true;  // will return new Set(...)

```

```
// ways arround empty string limit in DynamoDB

util.config.empty_string_replace_as = "\0";
// stringify() will return\0 and parse() will convert it back to ''


util.config.empty_string_replace_as = undefined; 
// stringify() will ignore the attribute for String and Map
// stringify() will leave it untouched for List ( DynamoDB will throw error instead ob breaking the index )
// stringify() will leave it untouched for StringSet ( DynamoDB will throw error  )



// stringify() will return null, parse() will convert it back to null ( looses the empty string )
util.config.empty_string_replace_as = null;

```

```

util.parse( { S: 'text' } ) 
    => 'text'

util.parse( { M: { number: {N: '1'}, string: {S: 'text'}, bool: { BOOL: true}, } } ) 
    => { number: 1, string: "text", bool: true }

util.stringify( 'text' ) 
    => { S: 'text'}

util.stringify( { number: 1, bool: true, } ) 
    => { 'M': { number: {N: '1'}, bool: { BOOL: true}, } }

util.stringify( { s1: new Set([1,2,3]), s2: new Set(['a','b','c']) } ) 
    => { 'M': { s1: {NS: ['1','2','3']}, s2: { SS: ['a','b', 'c']}, } }

// empty Set is converted as DynamoDB List
// mixed type Sets are also converted to DynamoDB List

util.stringify( { s1: new Set(), s2: new Set(['a',1) } ) 
    => { 'M': { s1: { L: [ ] }, s2: { L: [ 'a', 1 ]}, } }

```

## 常见问题

### @awspilot/dynamodb-util 是什么？

将 dinamodb 样式文档串行到对象中和对象外

### 如何安装 @awspilot/dynamodb-util？

在项目目录运行 npm install @awspilot/dynamodb-util，或使用 pnpm add / yarn add / bun add。

### @awspilot/dynamodb-util 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/awspilot\_\_dynamodb-util 是否存在。

### @awspilot/dynamodb-util 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @awspilot/dynamodb-util 可以商用吗？

@awspilot/dynamodb-util 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @awspilot/dynamodb-util 的下载量有多少？

根据 npm 官方下载统计，@awspilot/dynamodb-util 在 2026/10/08 – 2026/11/06 这 30 天内被下载 1,938 次，日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @awspilot/dynamodb-util 还在维护吗？

最新版本 1\.1\.4 发布于 2020/04/05（6 年前）；至今共发布 18 个版本，其中过去 12 个月发布了 0 个；首次发布于 2017/06/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

