@ninjakttty/dynamodb-object-normalizer

1.0.0 • Public • Published

Dynamodb object normalizer

Build Status License: MIT

Normalize JS objects for dynamodb insertion

Dynamodb doesn't like empty string, this will recursively drill through all the props with empty strings and remove them by default or replace them with a user defined string

Usage

const { normalize } = require('@ninjakttty/dynamodb-object-normalizer');

const item = {
  firstName: 'Yuri',
  lastName: '',
  age: 23,
  job: {
    title: 'developer',
    eprop: '',
    rank: 10,
    coworkers: ['Frank', 'Gary', 'Mark'],
  },
};

console.log(normalize(item));
/*
{ firstName: 'Yuri',
  age: 23,
  job:
   { title: 'developer',
     rank: 10,
     coworkers: [ 'Frank', 'Gary', 'Mark' ] } }
*/

console.log(normalize(item, { replaceWith: 'empty' }));
/*
{ firstName: 'Yuri',
  lastName: 'empty',
  age: 23,
  job:
   { title: 'developer',
     eprop: 'empty',
     rank: 10,
     coworkers: [ 'Frank', 'Gary', 'Mark' ] } }
*/

Installation

npm i @ninjakttty/dynamodb-object-normalizer

License

MIT © Yuri Parsons

Readme

Keywords

Package Sidebar

Install

npm i @ninjakttty/dynamodb-object-normalizer

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.9 kB

Total Files

5

Last publish

Collaborators

  • ninjakttty