title: Getting null value when trying to query value which is not present in dynamo db using node.js
body: <p>I am new to dynamoDB and node.js I have written a code where it will make a query to the database (dynamodb) and look for an element which is entered by the user in the database. I am able to verify that but when the user tries with some other number which is not present in the database I am getting a null value.</p>
  
  <p>My table name is "DevReferenceNumber" and only one column which is primary key "referencenumber".</p>
  
  <pre><code>    'use strict';
  
      var AWS = require('aws-sdk');
  
      var docClient = new AWS.DynamoDB.DocumentClient({ region : 'us-east-1'});
  
  
      function close(sessionAttributes, fulfillmentState, message) {
          return {
              sessionAttributes,
              dialogAction: {
                  type: 'Close',
                  fulfillmentState,
                  message,
              },
          };
      }
  
  
      exports.handler = (event, context, callback) =&gt; {
  
      try{
  
        console.log(`event.bot.name=${event.bot.name}`);
  
        if(event.bot.name != 'getCustomerReferenceNumber'){
            callback('Invalid Bot Name');
          }
  
        dispatch(event, (response) =&gt; {
  
            callback(null, response)
  
          });
  
      }catch(err){
  
  
          callback("Error is occured while querying");
  
      }
  
     };
     function dispatch(intentRequest, callback){
  
      console.log(`dispatch UserID =&gt; ${intentRequest.userId}, intentName =&gt; ${intentRequest.currentIntent.name}`);
  
      const intentName = intentRequest.currentIntent.name;
  
          if(intentName === "checkReferenceNumber"){
          return referenceNumber(intentRequest, callback);
  
          }
  
  
  
  }
  function referenceNumber(intentRequest, callback){
  
      const enteredReferenceNumber = intentRequest.currentIntent.slots.ReferenceNumber;
      const sessionAttributes = intentRequest.sessionAttributes;
  
      console.log("User has entered reference number is --&gt; " + enteredReferenceNumber);
  
      var params = {
  
          TableName : "DevReferenceNumber",
          KeyConditionExpression: "#refer = :ref",
          ProjectionExpression : "#refer",
          ExpressionAttributeNames: {
              "#refer" : "referencenumber"
          },
          ExpressionAttributeValues:{
              ":ref": parseInt(enteredReferenceNumber)
          }
      };
  
      docClient.query(params, function(err, data){
  
  
          if(err){
  
              callback(close(sessionAttributes, 'Fulfilled', {
                      contentType: 'PlainText',
                      content : 'Developer reference number is not matched with data from database'}));
          }
  
          else  {
  
              data.Items.forEach(function (item){
  
                  console.log("User matched data is ==&gt; " + item.referencenumber);
  
                  callback(close(sessionAttributes, 'Fulfilled', {
                      contentType: 'PlainText',
                      content : 'Developer reference number is matched with data from database'}));
              });
          }
  
  
  
      });
  }
  </code></pre>