Is there a good object mapper for Amazons dynamodb(through aws sdk) which can be used in nodejs?

前端 未结 6 1905
难免孤独
难免孤独 2021-02-01 03:07

Maybe the question does not apply to dynamoDB due to it not being Relational Db. However, I\'m looking for a good object mapper which can be used in nodejs and aws sdk to map e

6条回答
  •  轮回少年
    2021-02-01 03:25

    If you are using Typescript, dynamo-easy might be a good option. Just add some decorators to your model and start using it.

    import { Model, PartitionKey, DynamoStore } from '@shiftcoders/dynamo-easy'
    
    @Model()
    export class Person {
      @PartitionKey()
      id: string
      name: string
      yearOfBirth: number
    }
    
    const personStore = new DynamoStore(Person)
    
    personStore
      .scan()
      .whereAttribute('yearOfBirth').equals(1958)
      .exec()
      .then(res => console.log('ALL items with yearOfBirth == 1958', res))
    

    It uses the AWS DynamoDB sdk but takes care of the mapping between JS and DynamoDB types and provides a simple to use fluent API.

    full disclosure: I am one of the authors of this library

提交回复
热议问题