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: Get Multiple Items
- DynamoDB: Get Query
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Delete Table
- DynamoDB: Get By ID
- DynamoDB: GetItem
- DynamoDB: Query Count
- DynamoDB: Get Table
- DynamoDB: Attribute Not Null
- DynamoDB: Create if Not Exists
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Query Items
- DynamoDB Get in Typescript
- DynamoDB: Query Greater Than
- DynamoDB: Query Date Range
Login to the AWS Console less. Use Dynobase.
First 7 days are on us. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase