I have a shop owner and a shop owner can have multiple products. I want to keep the products id in an array.
Also, A public method can return all the product id list of a shop owner.
I tried the following code
pragma solidity 0.5.0;
contract Shop {
struct ShopOwner {
string id;
string[] productList;
}
struct Product {
string id;
string name;
}
mapping(string => ShopOwner) private mapShopOwner;
function getUserProductList(string _shopOwnerId) public view returns(string[]) {
return (mapShopOwner[_shopOwnerId].productList);
}
}
This seems does not support the solidity language.
I am getting the error
browser/Structure.sol:17:33: TypeError: Data location must be "memory" for parameter in function, but none was given. function getUserProductList(string _userId) public view returns(string[]) { ^------------^
and
browser/Structure.sol:17:69: TypeError: Data location must be "memory" for return parameter in function, but none was given. function getUserProductList(string _userId) public view returns(string[]) { ^------^
And I do not want to use pragma experimental ABIEncoderV2;
I wonder, what is the correct procedure to handle this types of relation.