Table Modify Assignment

Post your solutions here to the Table Modify Assignment.

ACTION helloworld::modify(uint64_t identifier, name new_owner, std::string new_name, uint64_t new_age){
  auto dog = _dogs.get(identifier, "Doggo not found");
  require_auth(dog.owner_name);
  auto dog_iterator = _dogs.find(identifier);
  _dogs.modify(dog_iterator, dog.owner_name,
  [&](auto& modify_dog){
    modify_dog.owner_name = new_owner;
    modify_dog.dog_name = new_name;
    modify_dog.age = new_age;
  });
}

I"ve left out the definition of the table but it seems to work without it, probably because I"ve added a declaration after defining the table type:

 typedef multi_index <name("dogs"), dog> dog_table;
  dog_table _dogs;
1 Like