0

I want to set a group vector as a secondary index in the user smart contract. group is the list of groups. Following is the changes I am doing:

struct [[eosio::table]] usertable {
                        name key;
                        std::string username;
                        std::string contact;
                        std::vector<name> group;

                        uint64_t primary_key() const { return key.value;}
                        uint64_t get_secondary_1() const { return group[value];}
                };

                typedef eosio::multi_index<"users"_n, usertable,indexed_by<"bygroup"_n, const_mem_fun<usertable, std::vector<name>, &usertable::get_secondary_1>>> user_index;

Its giving error

error: value of type 'uint64_t (user::usertable::)() const' is not implicitly convertible to 'std::__1::vector > (user::usertable::)() const' typedef eosio::multi_index<"users"_n, usertable,indexed_by<"bygroup"_n, const_mem_fun, &usertable::get_secondary_1>>> user_index;

I am not getting exactly how to give a vector of name type list as a secondary index. Please help and guide.

6
  • where's the value
    – Jimmy Guo
    Commented May 29, 2020 at 13:34
  • Do you want to search for an item with an arbitrary value in vector group? eosio allows only 5 types of secondary indices: uint64_t, uint128_t, checksum256, double, long double.
    – conr2d
    Commented May 29, 2020 at 19:38
  • I have list of group id's (in vector) which are in string format, and want to set the vector as secondary indices.
    – Varsh
    Commented Jun 1, 2020 at 2:16
  • @conr2d So, according to your comment, I cannot set a vector as a secondary indice!
    – Varsh
    Commented Jun 2, 2020 at 3:38
  • No, you can't. There can be some indirect ways to doing this, but its implementation would vary according to requirements. (The number of items in vector or the number of kinds of items, etc.)
    – conr2d
    Commented Jun 2, 2020 at 7:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.