I would get table entries by uuid. how can I convert string format 16cadf15-dda7-4be2-8026-c3c7875322d0
to an indexable eosio type ( uint64_t, uint128_t, uint256_t, double or long double).
Or even use as primary key if possible.
ACTION saveuuid(string uuid){
my_table mytable(_self, _self.value);
mytable.emplace(_self, [&]( auto& row ) {
row.id = mytable.available_primary_key();
row.uuid = uuid;
});
}
TABLE mytable {
int id;
string uuid;
uint128_t primary_key() const { return id; }
uint128_t by_uuid() const { return uuid.value; } // cast here?
EOSLIB_SERIALIZE( approvals, (id)(uuid));
};
typedef eosio::multi_index<"mytable"_n, mytable,
eosio::indexed_by<"mytable"_n, eosio::const_mem_fun<poll, string, &poll::by_uuid>>
> my_table;
TABLE mytable {
int id;
string uuid;
uint64_t primary_key() const { return id; }
uint128_t by_uuid() const { return uuid.value; }
EOSLIB_SERIALIZE( approvals, (id)(uuid));
};
typedef eosio::multi_index<"mytable"_n, mytable,
eosio::indexed_by<"mytable"_n, eosio::const_mem_fun<poll, string, &poll::by_uuid>>
> my_table;
ACTION saveuuid(string uuid){
my_table mytable(_self, _self.value);
mytable.emplace(_self, [&]( auto& row ) {
row.id = mytable.available_primary_key();
row.uuid = uuid; // how to cast ?
});
}