title: Scanning/querying specific entries in a dynamodb table with lambda
body: <p>I am working with AWS and using a API to trigger a lambda and the lambda contains CRUD code for the dynamodb. For example, this piece of code (in the lambda function) scans and returns all the objects:</p>
  <pre><code>app.get(path, function (req, res) {
    var params = {
      TableName: tableName,
      Select: 'ALL_ATTRIBUTES',
    };
  
    dynamodb.scan(params, (err, data) =&gt; {
      if (err) {
        res.json({ error: 'Could not load items: ' + err.message });
      }
  
      res.json({
        data: data.Items.map(item =&gt; {
          return item;
        }),
      });
    });
  });
  </code></pre>
  <p>This works nicely and i've been testing this with postman.
  I now want to query all items matching a specific ID from a table that is <strong>not</strong> the partition key. So for example: Imagine I have a database containing books. The PK is bookname. There is also an attribute that is bookyear. Multiple books can have bookyear 1997. And now I want to edit my query/scan so that it finds and returns me all books with bookyear 1997.
  What would be the best way to go about this?
  Thanks in advance.</p>
  <p>Edit nr 100:
  I am now using this code:</p>
  <p>Which is cool, because the query works now! The json.tringify(data) gives me the 2 database items I wanted, which is awesome!
  I am now trying to return this back to my test situation in postman. But unfortunately I get a &quot; &quot;message&quot;: &quot;Internal server error&quot;
  So I don't think returning data.Items is quite right.</p>