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

前端 未结 6 1767
难免孤独
难免孤独 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:09

    After looking over all the posts I landed on https://github.com/awspilot/dynamodb-oop

    It doesn't hide the API but instead just wraps it in a nice, fluent way with promises even and you inject your version of the aws-sdk. It's similar to dynamodb-data-types but also wraps the methods too (not just the data types).

    Extra bonus, the same author has https://github.com/awspilot/dynamodb-sql Didn't use the sql wrapper but I can see how some people may prefer that.

    Dynamoose is obviously inspired by mongoose and is a good choice if you have a well-defined schema and/or want to be abstracted away from the DynamoDB details.

    0 讨论(0)
  • 2021-02-01 03:10

    Also worth considering is simple marshallers, which just translate between the dynamoDB format and regular js objects or JSON.

    DynamoDb-Data-Types
    https://github.com/kayomarz/dynamodb-data-types
    https://www.npmjs.com/package/dynamodb-data-types

    "This utility helps represent AWS DynamoDb data types. It maps (marshalls) JavaScript data into the format required by DynamoDb."

    dynamoDb-marshaler
    https://github.com/CascadeEnergy/dynamoDb-marshaler https://www.npmjs.com/package/dynamodb-marshaler

    "Translates sane javascript objects (and JSON) into DynamoDb format and vice versa." [does not support B type.]

    Update 2016-06:
    Just discovered that the AWS SDK now does this for you. Their documentation is only partially converted so I guess this is a recent addition. Read about it here.

    But these marshallers are still useful because there are circumstances where you can't use the new document client, eg. when processing a dynamoDB stream.

    0 讨论(0)
  • 2021-02-01 03:17

    If you are looking for schema:

    • https://github.com/clarkie/dynogels (well supported forked from vogels which has been abandoned)
    • https://github.com/automategreen/dynamoose (inspired by Mongoose)

    If you are looking for something to throw javascript objects (even circular graphs) to:

    • https://github.com/aaaristo/dyngodb (alpha)
    • https://github.com/aaaristo/angular-gson-express-dyngodb

    dyngodb has experimental support for full-text search, and transactions too.

    Both are based on aws-sdk.

    0 讨论(0)
  • 2021-02-01 03:20

    Have you seen dynasaur? It seems to be the type of thing you're looking for, but I have not used it myself. There's also dynamodb-data-types which is not an ORM, but makes it easy to convert to/from standard JavaScript objects.

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2021-02-01 03:31

    You could also try: https://dynamoosejs.com/. It is inspired by mongoose again.

    0 讨论(0)
提交回复
热议问题