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: BatchGetItem
- DynamoDB: Get All Items
- DynamoDB: Query Group By
- DynamoDB: Get Query
- DynamoDB: Get Random Item
- DynamoDB: Create if Not Exists
- DynamoDB: Get List Of Items
- DynamoDB: Query Date Range
- DynamoDB: Not Begins With
- DynamoDB: Batch Get
- DynamoDB: Bulk Insert
- DynamoDB: Get Last Inserted Item
- DynamoDB: Attribute Not Null
- DynamoDB: Query Ends With
- DynamoDB BatchWriteItem in Typescript
Spend less time in the AWS console, use Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase