With Dynamodb is it possible to create an expression that will query an attribute that is a list of Objects. For example the POLICY_HOLDERS attribute on the table has the following JSON Structure
[
{PID: 1, FIRST_NAME: "Bob", LAST_NAME: "Smith"},
{PID: 2, FIRST_NAME: "Betty", LAST_NAME: "Johns"}
]
and I thought the following might work in to find all entries where the attribute POLICY_HOLDERS has an object in a list with FIRST_NAME equal to "Betty" (using the Java AWS SDK)
String filterExpressionString = "contains(POLICY_HOLDERS, :POLICY_HOLDER)";
expressionAttributeValues.put(":POLICY_HOLDER",
AttributeValue.builder()
.m(Map.of("FIRST_NAME", AttributeValue.builder().s("Betty").build()))
.build());
Is this even possible as the above finds nothing.
If you want to do a contains
for a list of maps, then you have to pass on the entire map, which is not desirable for your use-case.
contains(mylist, {PID: 2, FIRST_NAME: "Betty", LAST_NAME: "Johns"})