npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

json-dynamo-putrequest

v1.0.0

Published

Converts an arbitrary JSON into a DynamoDB PutRequest JSON to simplify the import of the raw data

Downloads

633

Readme

json-dynamo-putrequest

npm version CircleCI JavaScript Style Guide

Converts an arbitrary JSON into a DynamoDB PutRequest JSON to simplify the import of the raw data

The command basically takes a JSON string defining an array of objects as input and it converts to a JSON that contains an array of PutRequests suitable for loading the data in the original file in DynamoDB.

As an example if you have the following integers.json file as input:

[
  { "value": 1 },
  { "value": 2 }
]

and you run:

json-dynamo-putrequest integersTable integers.json --beautify

It will output:

{
  "integersTable": [
    {
      "PutRequest": {
        "Item": {
          "value": {
            "N": "1"
          }
        }
      }
    },
    {
      "PutRequest": {
        "Item": {
          "value": {
            "N": "2"
          }
        }
      }
    }
  ]
}

If you save this output in a file called integersDynamo.json you can then import the data directly in DynamoDB using the AWS command line client:

aws dynamodb batch-write-item --request-items file://integersDynamo.json

Install

Globally:

npm install --global json-dynamo-putrequest

Or as a dev dependency (e.g. you need it as part of your build process)

npm install --save-dev json-dynamo-putrequest

Usage

Using "pipes":

cat some.json | json-dynamo-putrequest tableName

Using input redirection:

json-dynamo-putrequest tableName < some.json

If you want to save the output to a file just use output redirection (or the --output option):

json-dynamo-putrequest tableName < some.json > dynamo.json
# OR json-dynamo-putrequest tableName --output dynamo.json < some.json

If you prefer to read the input from a file (rather then from the standard input) you can pass an extra parameter instead of using pipes or input redirection:

json-dynamo-putrequest tableName some.json

You can also beautify the output using the --beautify flag:

json-dynamo-putrequest --beautify tableName some.json

PRO-TIP: if you don't want to write json-dynamo-putrequest all the time, there is also the abbreviated alias jdp! :)

Command line options

You can display the live help by running:

json-dynamo-putrequest --help

Which will give you the list of all the available options and arguments:

json-dynamo-putrequest <tableName> [sourceFile]

Converts a JSON input into a JSON containing a set of DynamoDB PutRequests

Positionals:
  tableName   The name of the DynamoDB table                            [string]
  sourceFile  The source JSON file. If not specified the data will be read from
              the standard input                                        [string]

Options:
  --help          Show help                                            [boolean]
  --output, -o    the output file, if specified the output will be written in
                  the file
  --beautify, -b  the output file, if specified the output will be written in
                  the file                                             [boolean]
  --version       Show version number                                  [boolean]

Contributing

Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.

License

Licensed under MIT License. © Luciano Mammino.