Suppose I have this data structure layout:
struct ReviewStruct {
string rating;
...
}
struct Restaurant {
...
uint reviewCount;
mapping(uint => ReviewStruct) reviews;
}
uint public restaurantCount = 0;
mapping(uint => Restaurant) public restaurants;
Then, when I'm trying to access stuff in my JS app, it works, but not if I'm trying to access an actual review:
const restaurantCount = await review.methods.restaurantCount().call() // works
const restaurant = await review.methods.restaurants(2).call() // works
const reviewObj = await review.methods.restaurants(2).reviews(0).call() // throws an error
How do I access a mapping that is inside of a mapping (both are related to structs)?