I want to write a smart contract that:
Stores education certificates within the contact, and
Allow the users to search these records.
Each certificate is represented by a struct, Cert.
struct Cert {
uint256 ipfsId;
address issuerAddress;
address recipientAddress;
}
Once a struct is created I store them in maps so it's easier to retrieve them.
The user can retrieve certificates base on the certificate's ID, the issuer's address, or the receiver's address.
mapping (uint256 => Cert) certificates;
mapping (address => uint256) certificatesByIssuer;
mapping (address => uint256) certificatesByRecipient;
My issues are with the maps certificatesByIssuer and certificatesByRecipient.
Both maps can have duplicate keys if the same issuer issued multiple certificates
I can only retrieve one certificate at a time from the map which can be a problem if the same issuer issued multiple certificates.
Question:
Is there a way to avoid key duplication in my case? (For instance, switching the uint256 variable in both maps to a dynamic array, but how would I update the array then?)
Even if I resolve the issue in part 1, is it possible to retrieve multiple entries from the map all at once? (I plan to let the user interact with the contract through HTML browser interface.)