Tag: amazon dynamodb

查找DynamoDB属性未设置*或*大于x的项目

我试图从Lambda(Node.js)扫描一个DynamoDB表来检查一个令牌是否已经过期。 我想筛选数据,以排除设置了expiration_time项目并且小于当前时间。 我目前得到了没有设置expiration_time单位的误报。 我怎样才能检查过期的时间戳或没有expiration_time属性设置? dynamodb.scan({ "TableName": "fm_tokens", "AttributesToGet": ["user_id"], "ScanFilter": { "token": { "AttributeValueList": [{"S": tkn.toString()}], "ComparisonOperator": "EQ" }, "token_time": { "AttributeValueList": [{"N": expiration.toString()}], "ComparisonOperator": "GE" }, "expiration_time": { "AttributeValueList": [{"N": unix_timestamp.toString()}], "ComparisonOperator": "GE", } } }

不能使用UpdateItem从列表中删除元素

我试图从我的DynamoDB表中的ITEM中删除一个LIST元素。 我相信我有正确的设置,但似乎无法传递一个整数。 var params = { TableName: DB_TABLE_NAME, Key:{ "Key": KEY_VALUE }, UpdateExpression: "REMOVE List[:n]", ExpressionAttributeValues: { ":n": 1 }, ReturnValues:"UPDATED_NEW" }; 然后,我运行UpdateItem函数,我用于其他用例。 db.update(params, (err, data) => { console.log(data); }); 以下错误被返回 "message": "Invalid UpdateExpression: Syntax error; token: \":n\", near: \"[:n]\"", 当我删除ExpressionAttributeValues并用值1(它引用一个现有的List元素)replace:n ,它成功执行。 我明显失去了一些东西,任何帮助将不胜感激,谢谢!

带有DynamoDB属性值的Nodejs中的Lambda可能不包含空string

DynamoDB无法将空string作为属性中的值,因此遇到了问题。 如果存在空string值,我总是必须检查前端,否则API调用将失败,因为Dynamo DB将抛出错误“一个AttributeValue可能不包含空string”。 如果有一个recursion函数会根据DynamoDB删除无效的属性,以便使DynamoDB中的putItem或更新请求能够正常工作,那么我正在游荡。

如何使用Lambda和DynamoDB在date范围之间扫描?

我正在尝试使用节点Lambda函数在date范围之间扫描。 我有正确的数据被扫描,但我似乎无法让dateexpression式正常工作。 var AWS = require('aws-sdk'); var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); exports.handler = function(event, context) { var tableName = "MyDDBTable"; dynamodb.scan({ TableName : tableName, FilterExpression: "start_date < :start_date", ExpressionAttributeValues: { ":start_date": { "S": "2016-12-01" } } }, function(err, data) { context.succeed(data); }); }; 这目前不会尝试返回一个范围,它只是看着一个单一的date。 直到我知道这是行得通的时候,我才想添加一个andexpression式。 DynamoDB中的示例文档的结构如下所示: { "end_date": { "S": "2016-12-02" }, "name": { […]

不能更新Dynamo Db表,得到ValidationException

我需要通过仅使用分区键来更新我的Dynamo数据库表。 但我有validation的exeption。 我创build了一个3字段的表。 id(分区键) 名称(sorting键) 年龄 然后,我已经triyed更新年龄字段使用唯一ID(试图修改年龄30至40)这是我的代码 var AWS = require("aws-sdk"); AWS.config.update({ region: "us-east-1", }); var params = { TableName: 'test', Key: { id: '100' }, UpdateExpression: 'set #age = :age ', ConditionExpression: '#age = :testAge', ExpressionAttributeNames: { '#age': 'age' }, ExpressionAttributeValues: { ':age': '40', ':testAge': '30' } }; var docClient = new AWS.DynamoDB.DocumentClient(); docClient.update(params, […]

AWS – 在DynamoDB表中放置一个GeoPoing并对其进行查询 – node.js

Amazon现在支持 DynamoDB中的地理空间索引 ,但似乎没有太多关于如何使用node.js SDK来做到这一点的文档。 我试图了解如何: 将GeoPoint(geohash)值放入DynamoDB表中的项目中 和 如何查询半径范围内所有项目的表格(lat,lng) 我看过这篇文章,但不知道它是如何应用在node.js中,找不到任何示例

如何从Java脚本为DynamoDB中的预置读取容量启用Auto Scaling

我正在使用AWS SDK for nodejs并从代码创build一个dynamodb表。 这一切工作正常,但我需要自动缩放来启用预置的读取和写入容量。 这是我正在尝试的代码 var params = { TableName : "MyTable", KeySchema: [ { AttributeName: "Name", KeyType: "HASH"}, //Partition key { AttributeName: "time", KeyType: "RANGE" } //Sort key ], AttributeDefinitions: [ { AttributeName: "Name", AttributeType: "S" }, { AttributeName: "time", AttributeType: "N" } ], ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } ] }; […]

我有12个项目的限制,但dynamodb查询总是只返回10

我正在使用dynamodb npm查询dynamodb 当我查询如下,虽然我设置限制为12项 ,它总是返回10项 TableDB .query(lang) .filter('users').in(['case1','case2']) .attributes(['offerId', 'lang']) .ascending() .usingIndex('lang-date-index') .limit(12) .exec((err, data) => { console.log(data) } 我不想使用lastEvaluateKey再次查询下一个项目。 我错过了什么吗?

你如何unit testing一个NodeJs的Lambda函数写入/读取dynamodb,并通过AWS API网关端点调用?

我有一个lambda函数,通过对API网关端点的get / post请求调用,然后根据请求从/向DynamoDB表读/写的请求。 我怎样才能unit testingfunction? 我发现这个库叫做lambda-tester但是在处理Dynamo数据库的时候并不好用。 我也尝试过亚马逊的unit and load testing蓝图,但我不是一个很大的粉丝,因为它将结果写入另一个分布式数据库表,我宁愿只在本地进行testing,并在terminal上查看输出。

键上的条件数是无效的节点js的发电机数据库

docClient.update({ TableName: 'patient', Key: { "patientId": "TIGERPAT0001" }, UpdateExpression: "set title = :x, name = :y", ExpressionAttributeNames: { "#name": "name" }, ExpressionAttributeValues: { ":x": 'title value abc', ":y": 'name value xyz' } }, function (err, data) { if (err) { json.status = '0'; json.result = { 'error': 'Unable to Edit Patient : ' + JSON.stringify(err) […]