I have two current tables
user table:
| user_id (primary key) | map of devices owned by this user |
event table:
| id_device (primary key) | time_stamp (sort key) | data column | map of users tied to this device e.g [ {user_id: "A"}, {user_id: "B"} ] |
user_id:1 could have a number of devices e.g 1,2,3,4 user_id:2 could also be able to modify the same devices and have different ones as well e.g 2,3,4,5
The event table is literally the latest event made by any device on the network, table grows larger as events occur.
I want to be able to query the latest events for devices by a user.
Method 1: I was originally going to use the dynamoDB API (BatchGetItem) and pass the map of devices as the keys. However, I cannot do this since I need to provide the time_stamps.
Is there a way to scan/query the "map of users tied to this device" column such as only filtering for the "A" user in the map? I know scanning not recommended
Method 2: Have a secondary index of only the id_device as a primary key. Query each if the latest events and go into the "map of users tied to this device" map to see if the owner is there. If so append to an empty array to be returned.
Does anyone else have any recommendations? Thanks!