Great, now that our storage is initiated, let’s define the first CRUD operation.
The CREATE operation represents adding new entries to our persistent storage structure (player mapping). To insert a new player, we will define an addPlayer method, as follows:
function addPlayer(string _name, uint256 _phonenumber) public returns (bool) {
players[msg.sender].name = _name;
players[msg.sender].Paddress = msg.sender;
players[msg.sender].PhoneNumber = _phonenumber;
return true;
}
This function enables a new player to enroll themselves in the players, database. Similar to an INSERT statement, the different assignments will create (or, more accurately, fill) a new record in the mapping, indexed using the player address. By analogy, in SQL we can do the same thing using insert into players values (_name, _msg. sender, _phonenumber);.