I need to use a string as a id of table in my smart contract. Initially i found some answers that string can't be use as primary key. But i use string as a key in table as given below:
//@abi table tttab i64
struct tttab
{
string tableid;
vector<uint64_t> preowners;
uint64_t primary_key() const { return eosio::string_to_name(tableid.c_str()); }
EOSLIB_SERIALIZE(tttab, (tableid)(preowners))
};
typedef multi_index<N(tttab), tttab> __mytable;
this works fine for me. My question is : Is this a right approach to use string as a id?