While writing a contract that uses structs, I'm getting an error by the linter "Struct containing a (nested) mapping cannot be constructed".
According to this, the problem with structs is you cannot nest maps. In the design I'm using there's a map of uint8 => struct.
Should I switch to contracts or build a db scheme in the main contract?
Here's a sample code -
struct Room {
uint16 id;
}
struct Apartment {
uint8 id;
mapping(uint8 => Room) roomMap;
}
struct Building {
uint8 id;
mapping(uint8 => Apartment) apartmentMap; //error here
}
contract Network {
constructor() {}
uint8 count = 0;
mapping(uint8 => Building) public buildingMap;
function appendBuilding(uint8 id) public {
Building storage building;
building.id = id;
buildingMap[id] = building; //error here
}
}