3

I had the same question and ended up figuring it out by reading the multi_index.hpp from eosio.cdt code and wanted to share my solution. Instead of using auto, declare the type by using myindex::const_iterator: struct [[eosio::table]] _obj { name key; uint64_t primary_key() const { return key.value; } }; typedef eosio::multi_index<name("...


2

If you use a custom type you must also define the type to a built in type. A list of accepted types by EOSIO can be found here, https://eosio.stackexchange.com/a/1932/3333. For instance, your custom enum is actually a uint8_t type. You'll need something like .. ## header file enum e_vote_option { upvote = 0, downvote } typedef uint8_t vote_option; ...


2

If you don't care about the data from old_table: Erase all records from old_table Deploy NEWCONTRACT with modified old_table If you want to persist the data from old_table: Define the new and old structs/tables in NEW_CONTRACT1 Write a function that will move data from old_table to new_table; adding new column Deploy NEW_CONTRACT2 version that has ...


2

You need to include eosio.hpp before the other includes. #include <eosio/eosio.hpp> Sidenote: this actually seems to be a problem with cdt 1.6.1 and will hopefully be fixed with next releases Issue#532


1

You can search for an iterator with given key from multi_index first. iterator found: already created item, require_auth(user) iterator not found: not created item, require_auth(admin) Permission check can be done in any step of your method. (Even you call require_auth() at the last time of your method, its failure reverts all changes made during that ...


1

You can't access mongodb from smart contract at all. It is executed in closed and segregated context and can't communicate with external network except for internal state. Internal state here means data stored by eosio::multi_index. Once transaction is recorded, you can make a monitoring daemon to read it from block and do something for your demand like ...


Only top voted, non community-wiki answers of a minimum length are eligible