eos
eos copied to clipboard
Requesting support for string type primary key for DB
The following code gives an error because the DB does not support a string primary key:
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;
using namespace std;
class testc : contract {
using contract::contract;
private:
// @abi table
struct user_type {
string email_encrypted;
string password_hashed;
string isConfirmed;
string primary_key(){ return email_encrypted; }
EOSLIB_SERIALIZE( user_type, (email_encrypted)(password_hashed)(isConfirmed) )
};
typedef multi_index<N(user_table), user_type> user_table;
public:
testc( account_name self ) : contract(self){}
void add_update_user( string user ){
require_auth(N(appaccount));
user_table utable(_self,_self);
utable.get(user);
}
};
EOSIO_ABI( testc, (add_update_user) )
Error returned when compiled is:
testc.cpp:30:20: error: no viable conversion from 'string' (aka
'basic_string<char, char_traits<char>, allocator<char> >') to 'uint64_t'
(aka 'unsigned long long')
utable.get(user);
^~~~
... can support for string type primary key for DB be implemented? I suspect a lot of dapps may find this useful as it is a functionality that would fit for many use cases.
did you fix it ? i have the same issue
string primary key is currently not supported. There are plans to add it in the future.