Skip to main content
1 of 2

How should I get values from mapping?

Me and my friend are working on a hw assignment. We have a struct:

struct Record {
        string  id;
        uint requestTime;
        uint releaseTime;
        Direction dir;
    }

And we also have a mapping:

mapping(address => Record[]) data;

We will basically have multiple Record instances in the mapping associated with one address. Is there a way to read the Record instances from the mapping? Like a getter function or something that gets the specific address as a param and returns a Record[] array with the Record instances belonging to that address?

function getRecords(address _addr) public view returns(Record[]) {
    ...
    //returns recordsfound, which is a Record[]
    return recordsfound;
}

Or this doesn't work in Solidity and we have to make something else?