Guest User

Untitled

a guest
Dec 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. struct [[eosio::table]] poll
  2. {
  3. uint64_t key; // primary key
  4. uint64_t pollId; // second key, can be non-unique
  5. std::string pollName; // name of poll
  6. uint8_t pollStatus =0; // staus where 0 = closed, 1 = open, 2 = finished
  7. std::string option; // the item you can vote for
  8. uint32_t count =0; // the number of votes for each time
  9.  
  10. uint64_t primary_key() const { return key; }
  11. uint64_t by_pollId() const {return pollId; }
  12. };
  13.  
  14. _polls.emplace(get_self(), [&](auto& p) {
  15. p.key = _polls.available_primary_key(); // method
  16. p.pollId = _polls.available_primary_key();
  17. p.pollName = pollName;
  18. p.pollStatus = 0;
  19. p.option = "";
  20. p.count = 0;
  21. });
Add Comment
Please, Sign In to add comment