I'm struggling to find which way to send data to a struct is cheaper and most efficient. I came up with these 2 different styles:
struct Database
{
string name;
string addressPerson;
}
mapping (string => Database) idToDatabase;
function setPerson(string _id, string _name, string _address) external {
Database storage person = idToDatabase[_id];
person.name = _name;
person.addressPerson = _address;
}
and
struct Database
{
string name;
string addressPerson;
}
Database[] public people;
mapping (string => uint) idToPerson;
function setPerson(string _id, string _name, string _address) external {
people.push(Database(_name,_address));
idToPerson[_id] = people.length-1;
}
Which should I use and why? I researched a lot and couldn't find an answer. Thank you.