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 Table
- DynamoDB: Increment Counter
- DynamoDB: Get Last Inserted Item
- DynamoDB: Get Random Item
- DynamoDB: Not Begins With
- DynamoDB: Get All Items
- DynamoDB: Query Ends With
- DynamoDB: Get Query
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Query KeyConditionExpression
- DynamoDB: Delete All Items With Partition Key
- DynamoDB Get in Typescript
- DynamoDB: Bulk Insert
- DynamoDB: Attribute Not Null
- DynamoDB: Get Table
Login to the AWS Console less. Use Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase