For suppose the item is like
{
'EventType': 'git/push'
'EventTime': 1416251010,
'Commits': [
{
'id': '29d02aff...',
'subject': 'Add the thing to the place'
},
{
'id': '9d888fec...',
'subject': 'Spelling errors'
},
...
]
}
then I want the output like
{
'EventType': 'git/push'
'EventTime': 1416251010,
'Commits': [
{
'id': '29d02aff...',
'subject': 'Add the thing to the place'
}
]
}
can you please suggest me the DynamoDB filter. Thanks in advance.
CONTAINS function can be used to filter or find the data in DynamoDB list. However, please note that you need to have both the attributes (i.e. id and subject) of the object (complex object in terms of DynamoDB) to find the data in List.
CONTAINS is supported for lists: When evaluating "a CONTAINS b", "a" can be a list; however, "b" cannot be a set, a map, or a list.
Sample code:-
var table = "eventtype";
var params = {
TableName: table,
KeyConditionExpression: "EventType = :eventType",
FilterExpression: "contains(Commits, :commitVal )",
ExpressionAttributeValues: {
":eventType": 'git/push',
":commitVal": {
'id': '29d02aff',
'subject': 'Add the thing to the place'
}
}
};
docClient.query(params, function (err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err,
null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With