title: DynamoDB query using AWS Lambda
body: <p>I am trying to select an entry from my database with id "1" (primary key) I am not sure what I am doing wrong, I also tried .getItem() method however with no positive result. </p>
  
  <pre><code>'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);
          }
      });
  }
  </code></pre>
  
  <p>I am trying to build serverless REST API using AWS lambda, .scan() works perfectly but I want to filter the data. I have 2 values for each user in database, id(primary key(string)) and status (string).</p>
  
  <p>FIXED UPDATE:</p>
  
  <pre><code>'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);
          }
      });
  }
  </code></pre>