AWS开发工具包DynamoDB客户端和DocumentClient之间的区别?

编程入门 行业动态 更新时间:2024-10-28 06:33:05
本文介绍了AWS开发工具包DynamoDB客户端和DocumentClient之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道AWS开发工具包DynamoDB客户端和DynamoDB DocumentClient之间的区别吗?在哪种用例中,我们应该在DocumentClient上使用DynamoDB客户端?

I want to know the difference between the AWS SDK DynamoDB client and the DynamoDB DocumentClient? In which use case should we use the DynamoDB client over the DocumentClient?

const dynamoClient = new AWS.DynamoDB.DocumentClient(); vs const dynamo = new AWS.DynamoDB();

推荐答案

我认为这是最好的答案通过比较两个做相同事情的代码示例。

I think this can be best answered by comparing two code samples which do the same thing.

这是使用dynamoDB客户端放置项目的方式:

Here's how you put an item using the dynamoDB client:

var params = { Item: { "AlbumTitle": { S: "Somewhat Famous" }, "Artist": { S: "No One You Know" }, "SongTitle": { S: "Call Me Today" } }, TableName: "Music" }; dynamodb.putItem(params, function (err, data) { if (err) console.log(err) else console.log(data); });

以下是使用DocumentClient API放置同一项目的方法:

Here's how you put the same item using the DocumentClient API:

var params = { Item: { "AlbumTitle": "Somewhat Famous", "Artist": "No One You Know", "SongTitle": "Call Me Today" }, TableName: "Music" }; var documentClient = new AWS.DynamoDB.DocumentClient(); documentClient.put(params, function (err, data) { if (err) console.log(err); else console.log(data); });

在 DocumentClient 中可以看到 Item 以更自然的方式指定。在所有其他更新DDB的操作( update(), delete())和返回的项目中也存在类似的区别从读取操作( get(), query(), scan())。

As you can see in the DocumentClient the Item is specified in a more natural way. Similar differences exist in all other operations that update DDB (update(), delete()) and in the items returned from read operations (get(), query(), scan()).

更多推荐

AWS开发工具包DynamoDB客户端和DocumentClient之间的区别?

本文发布于:2023-11-25 01:08:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627693.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具包   客户端   区别   AWS   DocumentClient

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!