dynamodb-json-schema

Generate dynamodb table schema from json schema

Usage no npm install needed!

<script type="module">
  import dynamodbJsonSchema from 'https://cdn.skypack.dev/dynamodb-json-schema';
</script>

README

dynamodb-json-schema Build Status

Generate dynamodb table schema from json schema

Example Usage

import * as fs from "fs";
import { getTableSchema } from "dynamodb-json-schema";

const USER_SCHEMA = JSON.parse(fs.readFileSync("User.json", "utf8"));

const tableSchema = getTableSchema({
  tableName: "users-table",
  hashKey: "id",
  itemSchema: USER_SCHEMA
});

/*
=> {
  "TableName": "users-table",
  "KeySchema": [{
    "AttributeName": "id",
    "AttributeType": "HASH"
  }],
  "AttributeDefinitions": [{
    "AttributeName": "id",
    "AttributeType": "S"
  }]
}
*/