Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用AWS Lambda的DynamoDB查询_Amazon Web Services_Aws Lambda_Amazon Dynamodb_Aws Sdk_Aws Api Gateway - Fatal编程技术网

Amazon web services 使用AWS Lambda的DynamoDB查询

Amazon web services 使用AWS Lambda的DynamoDB查询,amazon-web-services,aws-lambda,amazon-dynamodb,aws-sdk,aws-api-gateway,Amazon Web Services,Aws Lambda,Amazon Dynamodb,Aws Sdk,Aws Api Gateway,我正在尝试从数据库中选择id为“1”(主键)的条目。我不确定我做错了什么,我也尝试了.getItem()方法,但没有任何积极的结果 'use strict'; var AWS = require('aws-sdk'), documentClient = new AWS.DynamoDB.DocumentClient(); exports.selectStatus = function(event, context, callback){ documentClient.que

我正在尝试从数据库中选择id为“1”(主键)的条目。我不确定我做错了什么,我也尝试了.getItem()方法,但没有任何积极的结果

'use strict';

var AWS = require('aws-sdk'),
    documentClient = new AWS.DynamoDB.DocumentClient(); 

exports.selectStatus = function(event, context, callback){
    documentClient.query({TableName : "users", Key:{"id":"1"}}, function(err, data){
        if(err){
            callback(err, null);
        }else{
            callback(null, data.Items);
        }
    });
}
我正在尝试使用AWS lambda构建无服务器REST API,.scan()工作得很好,但我想过滤数据。对于数据库中的每个用户,我有2个值,id(主键(字符串))和status(字符串)

固定更新:

'use strict';

var AWS = require('aws-sdk'),
    documentClient = new AWS.DynamoDB.DocumentClient(); 

exports.selectStatus = function(event, context, callback){
var params = {
    TableName : "users",
    KeyConditionExpression: "id = :id",
    ExpressionAttributeValues: {
        ":id": "1"
    }
};
    documentClient.query(params, function(err, data){
        if(err){
            callback(err, null);
        }else{
            callback(null, data.Items);
        }
    });
}