FilterExpression
は(条件1) OR ( (条件2) AND (条件3) )
の様にネストできる。
var item = 'hoge';
var shipping_state1 = 'shippingA';
var shipping_state2 = 'shippingB';
var params = {
TableName: 'Item',
FilterExpression: '(items = :items) AND ((shipping_state=:shipping_state1) OR (shipping_state=:shipping_state2))',
ExpressionAttributeValues: {
':items':item,
':shipping_state1':shipping_state1,
':shipping_state2':shipping_state2
}
}
dynamodb.scan(params).promise().then(function(data) {
console.log(data);
}).catch(function (error) {
console.log(error)
})
IN
を使う場合は(キー IN (:候補1,:候補2,:候補3)
のようにする。
var item = 'hoge';
var shipping_state1 = 'shippingA';
var shipping_state2 = 'shippingB';
var params = {
TableName: 'Site',
FilterExpression: '(items = :items) AND (shipping_state IN (:shipping_state1,:shipping_state2,:shipping_state3))',
ExpressionAttributeValues: {
':items':item,
':shipping_state1':shipping_state1,
':shipping_state2':shipping_state2
}
}
dynamodb.scan(params).promise().then(function(data) {
console.log(data);
}).catch(function (error) {
console.log(error)
})