@awspilot/dynamodb-util

中文文档
1.1.4发布于 2020/04/05ISCCommonJS零依赖近 30 天下载 1938

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

中文使用文档

烟花花

Build Status License Dependencies

将 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 共发布 18 个版本,首次发布于 2017/06/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.4latest2020/04/056 年前
1.1.32020/01/156 年前
1.1.22020/01/056 年前
1.1.12020/01/046 年前
1.1.02020/01/046 年前
1.0.122019/11/136 年前

关于 @awspilot/dynamodb-util 的常见问题

@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 和提交记录判断。