I'm trying to make a get function based on date(in timestamp) Do I need another mapping? Take into consideration that it might be more than one registries on the same date. Any help is great. :)
struct Route{
uint id;
uint date;
string driverName;
string routeBinId;
}
mapping(uint256 => Route) routes;
// Set/Store Data
function setRouteData( uint256 _date, string memory _driverName, string memory _routeBinId)
public _ownerOnly payable {
routes[routeId] = Route(routeId, _date, _driverName, _routeBinId);
routeId++;
}
// Get All Data
function getRouteData() external view _ownerOnly returns (Route[] memory){
Route[] memory id = new Route[](routeId);
for (uint i = 0; i < routeId; i++) {
Route storage route1 = routes[i];
id[i] = route1;
}
return id;
}
// Get Data based on Id
function getRouteDataBasedOnId(uint _routeId) external view _ownerOnly returns(Route memory){
return routes[_routeId];
}
}