I use solidity to store users information so before that i want to check if the user id already exist or no, Can any one help me with this code ?
i see some solution using array or require all parameters of structure and i don't prefer that, can i do this without these choices?
this function to store user information, if any one have a better code for that, i will appreciate it.
contract Contract {
struct User{
string fname;
string Email;
uint256 age;
}
mapping(uint => User)public users;
function addDoctor(uint _id, string memory fname, string memory Email,
uint256 age) public {
users[_id] = User(fname,email,age);
}
}
thanks in advanced.