I have a base DDB table Attachment
and it has 2 fields called customerState
and isIntermediateState
.
customerState can be Attaching
, Detaching
, Attached
and Detached
.
isIntermediateState can be 1
(if customerState == Attaching || Detaching
) or 0
(if customerState == Attached || Detached
).
The customerState will go from Attaching/Detaching -> Attached/Detached.
Now I want to construct a GSI where I only want to add records from the base Attachment
table if isIntermediateState = 1 and remove the records (eventually) when the isIntermediateState = 0, or the customerState becomes Attached || Detached
.
Does GSI in DynamoDb allow conditionally adding and removing records from the index based on the values of the fields in the base table? Also, will it continue updating the index as the base table updates or only while initially adding the record, will it be decided whether to add to index or not?