Suppose I have the following contract:
contract UserContract {
struct User {
address walletAddress;
string organisation;
string fName;
string lName;
string email;
uint index;
}
mapping(address => User) private users;
address[] private userIndex;
}
I know how to write a function that returns user information corresponding to a given address
, but I'd also like to write a function that can grab user info by the User
's email address.
How does this work? Is my only option to create a separate mapping for this use-case that maps the User
struct to a string? If so, does this mean the struct gets stored two times? Or does it only store references to that struct?
Thanks!