Get unlimited public & private packages + package-based permissions with npm Pro.Get started »


1.12.2 • Public • Published

Build Status npm version Semantic Release enabled Dependabot Status


Elegant DynamoDB object modeling for Typescript.

Let's face it, all good databases need good model casting. DynamoDB is powerful but libraries that used it were not. That's where Dyngoose comes in.

Read the docs!


  1. Cast your tables, attributes, and indexes using TypeScript classes.
  2. Generate your CloudFormation templates based on your code, or perform your table operations on demand; see Deployment.
  3. Intelligent and powerful querying syntax, see Querying.
  4. Selectively update item attributes, prevents wasteful uploading of unchanged values.
  5. Data serialization, cast any JavaScript value into a DynamoDB attribute value.
  6. DynamoDB Accelerator (DAX) and Amazon X-Ray support, see Connections.
  7. Optimizes connection to DynamoDB HTTP service using Keep-Alive, see Code.
  8. Incredibly easy local development, with supporting for seeding a local database.
  9. Supports conditional writes, see Saving.

Example Usage

import { Dyngoose } from 'dyngoose'
@Dyngoose.$Table({ name: 'Card' })
class Card extends Dyngoose.Table {
  public id: number
  public title: string
  @Dyngoose.Attribute.Date({ timeToLive: true })
  public expiresAt: Date
  @Dyngoose.$PrimaryKey('id', 'title')
  static readonly primaryKey: Dyngoose.Query.PrimaryKey<Card, number, string>
  static readonly writer: Dyngoose.DocumentClient<Card>
// Perform table operations
await Card.createTable()
await Card.deleteTable()
// Creating records
const card = new Card() = 100
card.title = 'Title'
// note: is correct, this is a custom method that allows for a strongly-typed object
const card2 ={
  id: 100,
  title: 'Title'
// Save a record
// Batch Put
await Card.documentClient.batchPut([,
// Get record by the primary key
await Card.primaryKey.get(100, 'Title')
// BatchGet
// This array is strongly typed such as Array<[number, string]> so don't worry.
await Card.primaryKey.batchGet([
  [100, 'Title'],
  [200, 'Title2']
// Query
// Queries are always strongly typed. (['>=', T] | ['=', T] ...)
await Card.primaryKey.query({
  id: 100,
  title: ['>=', 'Title']
// Delete record
await card.delete()

TS Compiler Setting

Dyngoose utilizes TypeScript decorators, to use them you must enable them within your tsconfig.json file:

    "compilerOptions": {
        // other options
        "experimentalDecorators": true, // required
        "emitDecoratorMetadata": true // required

Honorable mentions

I originally based a lot of of this work on Dynamoose, reworking it for TypeScript and adding adding better querying logic. About two years later, I pulled in some work from dynamo-types and reworked it further to make what has become Dyngoose. I want to thank the creators and all the people who worked on both of those projects.


npm i dyngoose

DownloadsWeekly Downloads






Unpacked Size

283 kB

Total Files


Last publish


  • avatar