how do I query dynamodb for all items that match a specific rule?
I am building an online shop (like Asos) and in dynamodb I have a products table. all of the products have the field 'category'. so I just want to do a simple query whereby I say something like
FROM products WHERE category == 'trainers'
I have managed to get it working so I scan the whole table and return me all the products but i want more specific queries now
I assume I want to use something like: KeyConditionExpression
but I keep getting an error when I do this
edited question:
code:
componentDidMount() {
console.log('mounted');
const AWS = window.AWS;
const params = {
TableName: 'Products',
FilterExpression: "category = trainers"
};
...secret key code
ddb.scan(params, (err, data) => {
if (err) {
console.log(err, err.stack);
} else {
console.log(data);
this.setState({ products: data })
}
});