title: Dynamo DB Query Filter Node.js
body: <p>Running a Node.js serverless backend through AWS. </p>
  
  <p><strong>Main objective:</strong> to filter and list all LOCAL jobs (table items) that included the available services and zip codes provided to the filter.</p>
  
  <p>Im passing in multiple zip codes, and multiple available services.</p>
  
  <p><code>data.radius</code> would be an array of zip codes = to something like this:<code>[ '93901', '93902', '93905', '93906', '93907', '93912', '93933', '93942', '93944', '93950', '95377', '95378', '95385', '95387', '95391' ]</code></p>
  
  <p><code>data.availableServices</code> would also be an array = to something like this <code>['Snow removal', 'Ice Removal', 'Salting', 'Same Day Response']</code></p>
  
  <p>I am trying to make an API call that returns only items that have a matching <code>zipCode</code> from the array of zip codes provided by <code>data.radius</code>, and the <code>packageSelected</code> has a match of the array <code>data.availableServices</code> provided.</p>
  
  <p><strong><em>API CALL</em></strong>   </p>
  
  <pre><code>import * as dynamoDbLib from "./libs/dynamodb-lib";
  import { success, failure } from "./libs/response-lib";
  
  export async function main(event, context) {
    const data = JSON.parse(event.body);
    const params = {
      TableName: "jobs",
      FilterExpression: "zipCode = :radius, packageSelected = :availableServices",
      ExpressionAttributeValues: {
        ":radius": data.radius,
        ":availableServices": data.availableServices
      }
    };
  
    try {
      const result = await dynamoDbLib.call("query", params);
      // Return the matching list of items in response body
      return success(result.Items);
    } catch (e) {
      return failure({ status: false });
    }
  </code></pre>
  
  <p>Do I need to map the array of zip codes and available services first for this to work?</p>
  
  <p>Should I be using comparison operators? 
  <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.QueryFilter.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.QueryFilter.html</a></p>
  
  <p>Is a sort key value or partition key required to query and filter? (the table has a sort key and partition key but i would like to avoid using them in this call)  </p>
  
  <p>Im not 100% sure on how to go about this so if anyone could point me in the right direction that would be wonderful and greatly appreciated!! </p>