I’m trying to design a GSI for my table which contains a lot of data. However I know that its best practice to only project data that I need instead of the entire thing. Projecting data is pretty straight forward when it comes to Top-Level entities but in my use case I also need to project some of the contents of a map object
To give you more detail, here is my partial schema –
Name,
id,
url,
stats {
revenue: {
revenue: 123,
total_orders: 123,
}
social: {}
}
and I want to project name, url and total_orders. Is there a way of projecting all three without projecting the whole stats object ?
2
Answers
Sorry, no. You can only specify by name(s) what attribute to project.
Only top level attributes can be projected. So for your case you would have 2 possible options:
Project the entire
stats
map if it’s not extremely largeWrite
total_orders
as a top level attribute. This would cause duplication but it would be negligible.