How can I map multiple struct instances to one user without overriding the previous instance? I want to retrieve both instances through one mapping query. Should I use a multi-dimensional array here or a nested mapping?
As an example. If I have the below two structs. The problem is that the cookie mapping will only retrieve the latest cookie hidden by the cookieContributor but I want to retrieve all the cookies contributed by this particular address? How should my mapping look to achieve this?
contract HiddenCookies {
struct Cookie {
string cookieID
string name,
string color,
string flavor,
uint amount
}
struct CookieJar {
address[] cookieContributors;
mapping(address => Cookie[]) cookies;
Cookie[] cookieJarContent;
uint cookiesHiddenForLater;
}
}
mapping(address => YourStruct[])
should do the job, though it's hard to say for sure, when relying on your extremely too-broad description!