I'm having a huge dilemma! I'm developping a smart contract that has, let's say Struct A
and Struct B
. Because I want to have a function retrieving all objects type A
and B
, I created a Struct All
that is as follows:
struct All {
A[] a;
B[] b;
}
struct A {...}
struct B {...}
This way, I could create objects of both types and append them to the [] of each.. in the end, I would return the All
in case I want to get all a
and b
or All.a
or All.b
if convenient. So far so good. Although, now when it comes to deleting and editing it is much harder and I have to iterate through all the arrays and delete or change the one I want, and shift or something else needed. So I thought, ok, maps are easier to do this. But on the other and, with a map, I can not just retrieve the full content of both structs.
I know this ain't a straight question, rather a looking for help, hoping for someone who has crossed the same situation or knows how to handle this type of contract designing dilemma.
Basically, I would like to be able to retrieve all the different types of structs I may have, but also want to be able to edit the pool where they sit. Is there any suggestion?