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

serverless-dynamodb-fixtures-plugin

v1.0.1

Published

Serverless plugin to preload static data into dynamodb, primarily aimed at helping you load data to test your accessor layer.

Downloads

9

Readme

serverless-dynamodb-fixtures-plugin

This is a plugin for Serverless

It will help you load up some static data into your DynamoDB tables.

Useful for either canned data or to provide consistent test-data across environments.

Installation

npm install serverless-dynamodb-fixtures-plugin --save

Then add serverless-dynamodb-fixtures-plugin to your plugins array in s-project.json

  "plugins": [
    "serverless-dynamodb-fixtures-plugin"
  ]

Usage

Create a fixtures directory in the root of your project. Populate it with json files of the format:

{
    "tableName": YOURTABLENAME, 
    "entries":[
        ENTRIES TO ADD
    ]
}

Here's an example with some data in it.

{
  "tableName": "${SERVERLESS_STAGE}-${SERVERLESS_PROJECT}-car", 
  "entries":[
    {"id":"test-car-1", "make":"Subaru Forrester", "mileage":32000, "year":2010},
    {
      "id":"test-car-2",
      "make":"Audi TT",
      "mileage":132000,
      "year":2004,
      "previous_owner": {
        "name": "Marc",
        "comments": [
          "Was fun to drive.",
          "Never in an accident"
        ]
      }

    },
    {"id":"test-car-3", "make":"Ford Mustang", "mileage":57021, "year":2016},
    {"id":"test-car-4", "make":"Delorean", "mileage":2000000, "year":1986},
    {"id":"test-car-5", "make":"Intentionally Missing Mileage", "year":2010},
    {"id":"test-car-${SERVERLESS_STAGE}", "make":"Intentionally Missing Mileage", "year":2010}
  ]
}

Then run:

sls dynamoddb load

You should see something like this:

Serverless: Loading fixtures to stage "dev" in region "us-east-1"...  
Serverless: Loading fixtures/cars.json  
Serverless: Writing 6 entries  
Serverless: Loading fixtures/cars2.json  
Serverless: Writing 25 entries  
Serverless: Writing 21 entries  

If it starts taking a long time, you're probably hitting your write throughput limit, just wait and it should finish.

Optionally specify stage and/or region

NOTE: This uses a dynamoDB batch write operation which completely overwrites the items specified. If you have records with the same keys, they will be overwritten. If you have properties in your existing data that don't exist in the JSON, they will be lost.

Limitations

Right now, only the variables SERVERLESS_STAGE, SERVERLESS_REGION, and SERVERLESS_PROJECT can be used within the json.