I'll dive right in. I am using ScanamoAlpakka
.
I have the following:
Map(
'field1 -> value1,
'field2 -> value2,
and so on...
)
The goal is to iterate the map and remove any empty values. Once the empty values are removed, I need to transform each key/value pair into a query condition based on its type.
Like so:
mapObject
.collect({
case (key, Some(value: DateRange)) => key between (value.after and value.before)
case (key, Some(value)) => key -> value
})
.reduce(_ and _)
This does not work because the conditions outlined above do not immediately become objects of a query condition class. I have been looking through the SDK and have had difficulty finding a class that would transform the key/value pairs into a queryable condition.
I have tried using Condition(key, value)
which appears to work, however when done in this format it appears all of the implicits that apply for DynamoFormat
are lost, as I get the following error:
Error:(22, 45) could not find implicit value for evidence parameter of type com.gu.scanamo.query.ConditionExpression[(Symbol, Any)]
case (key, Some(value)) => Condition(key -> value)