【发布时间】:2014-10-14 12:24:22
【问题描述】:
我正在使用全局二级索引来查询我的表,并希望能够根据其他属性过滤结果(SQL 等效项是 WHERE 子句))。扫描允许我这样做,但可以使用查询吗?我还可以采取哪些其他方法?
var params = {
"IndexName": "City-index",
"KeyConditions": {
"City": {
"AttributeValueList": [{
"S": city
}],
"ComparisonOperator": "EQ"
}
},
"Limit": "100",
"TableName": "properties"
}
dynamoDB.query(params, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
});
关于如何设计 TABLE 来实现的任何其他想法:
Hash Key: propertyID (unique)
Range Key: createdAt (unique
Global Secondary Indexes: City
Global Secondary Indexes: State
我希望能够按索引进行查询,然后按其他属性(卧室、浴室等)进行过滤
【问题讨论】:
标签: javascript node.js amazon-dynamodb