问题
I have Table with following items where p_id is Primary partition key and p_type (String) is a Primary sort key.
p_id p_type address name phone
1221 Men
I want to write query in node js function with this condition: "select all where p_type ="men" and address.area="abc".
my address item is a map and it looks like this:
"address": {
"M": {
"area": {
"S": "abc"
},
"city": {
"S": "Bengaluru"
},
}
How to achieve this. do i have to create global secondary index?if yes how to create it.
回答1:
You cannot use
Query
based on the sort key.
Query
work when you createGSI
top_type
.
Another solution is
You can use
scan
operator instead ofquery
来源:https://stackoverflow.com/questions/53167165/how-to-query-based-on-condition-in-dynamo-db-table