阅读背景:

Amazons dynamodb(通过aws sdk)是否有一个好的对象映射器可以在nodejs中使用?

来源:互联网 

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 existing model classes to dynamoDB tables. Does anyone have experience with this issue/question, or have you used such a module/library?

也许这个问题不适用于dynamoDB,因为它不是关系型Db。但是,我正在寻找一个好的对象映射器,它可以在nodejs和aws sdk中用于将现有的模型类映射到dynamoDB表。有没有人有这个问题/问题的经验,或者您是否使用过这样的模块/库?

5 个解决方案

#1


22  

If you are looking for schema:

如果您正在寻找架构:

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

如果您正在寻找能够将javascript对象(甚至是圆形图形)抛出到:

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

dyngodb也支持全文搜索和事务处理。

Both are based on aws-sdk.

两者都基于aws-sdk。

#2


5  

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

另外值得考虑的是简单的marshallers,它只是在dynamoDB格式和常规js对象或JSON之间进行转换。

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

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."

“此实用程序有助于表示AWS DynamoDb数据类型。它将JavaScript数据映射(marshalls)为DynamoDb所需的格式。”

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

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.]

“将理智的javascript对象(和JSON)转换为DynamoDb格式,反之亦然。” [不支持B类型。]

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.

更新2016-06:刚刚发现AWS SDK现在为您执行此操作。他们的文档只是部分转换,所以我想这是最近添加的。在这里阅读它。

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.

但是这些marshallers仍然有用,因为在某些情况下你不能使用新的文档客户端,例如。处理dynamoDB流时。

#3


2  

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

您也可以尝试:https://dynamoosejs.com/。它再次受到猫鼬的启发。

#4


1  

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

查看了所有帖子后,我登陆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).

它并没有隐藏API,而只是以一种漂亮,流畅的方式包装它甚至承诺你注入你的aws-sdk版本。它类似于dynamodb-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.

额外的奖金,同一作者有https://github.com/awspilot/dynamodb-sql没有使用sql包装,但我可以看到一些人可能更喜欢这样。

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.

Dynamoose显然受到猫鼬的启发,如果你有一个明确定义的架构和/或想要从DynamoDB细节中抽象出来,那么它是一个很好的选择。

#5


0  

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.

你见过dynasaur吗?它似乎是你正在寻找的东西,但我自己没有用过它。还有dynamodb-data-types,它不是ORM,但可以很容易地转换为标准JavaScript对象/从标准Ja​​vaScript对象转换。


分享到: