DynamoDB: Not Between (Guide w/ Code Examples)

Provided by Rafal Wilinski
The AWS JavaScript SDK does not have a method for performing a "not between" query on a table. However, you can use the query
operation to retrieve items where the value of a specific attribute is less than a given value and greater than another given value.
const params = { TableName: "myTable", KeyConditionExpression: "#age between :minAge and :maxAge", ExpressionAttributeNames: { "#age": "age" }, ExpressionAttributeValues: { ":minAge": 20, ":maxAge": 30 } }; dynamodb.query(params, function(err, data) { if (err) { console.error("Unable to query. Error:", JSON.stringify(err, null, 2)); } else { console.log("Query succeeded."); data.Items.forEach(function(item) { console.log(" -", item.age + ": " + item.info); }); } });
Similar Code Examples
- DynamoDB: Delete Multiple Items in Javascript
- DynamoDB: Get Last Inserted Item
- DynamoDB: Query Ends With
- DynamoDB: Get By ID
- DynamoDB: Query Date Range
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Get All Items
- DynamoDB: Like
- DynamoDB: Query Group By
- DynamoDB: Get Table
- DynamoDB: Get Query
- DynamoDB: Batch Get
- DynamoDB: Query KeyConditionExpression
- DynamoDB Get in Typescript
- DynamoDB: Attribute Not Null
Tired of AWS Console? Try Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase