0.2.0-alpha • Published 3 years ago
dynamo-parser v0.2.0-alpha
dynamo-parser
Parse, don't validate
This package is in early development, and things may change at any time!
dynamo-parser
is a tool to work with AWS DynamoDB built with TypeScript. Using the power of zod, you get static type inference as well as ensuring that all your records match your schema!
Installation
# with yarn
yarn add dynamo-parser
# or npm
npm i dynamo-parser
Usage
Your journey starts with the Item
:
import { Item } from 'dynamo-parser';
import z from 'zod';
const Book = new Item(
'books-table',
{
title: z.string(),
rating: z
.number()
.min(1)
.max(5),
},
['title']
);
Item
needs a table name, the schema of your item, and the primary attribute names of the item. You can optionally specify other options, including plugging in your own instance of AWS.DynamoDB.DocumentClient
(defaults to "us-west-2"
).
You can then call various methods on your Item
, including:
Book.new({
title: 'Ready Player One',
rating: 5,
});
Book.get({ title: 'Ready Player Two' });
Book.all(); // get all items from the table
Created with 💖 with tsdx.
0.2.0-alpha
3 years ago
0.1.4-alpha
3 years ago
0.1.3-alpha
3 years ago
0.1.2-alpha
3 years ago
0.1.1-alpha
3 years ago
0.1.0-alpha
3 years ago