As I said I need to get the count of rows in a table. Preferly via rpc with http plugin or from a new action inside the Smart Contract.
This is my Smart Contract:
#include <eosio/eosio.hpp>
using namespace eosio;
// The contract
class [[eosio::contract("crud")]] crud : public eosio::contract {
public:
// Use contract's constructor
using contract::contract;
[[eosio::action]]
void create(name user,uint64_t id, std::string data) {
require_auth (user);
cif_index cifrados (get_self(), get_self().value);
auto iterator = cifrados.find(id);
if (iterator == cifrados.end()){
cifrados.emplace(get_self(), [&] (auto& row){ //Create
row.id = id;
row.cif = data;
});
}else{
cifrados.modify(iterator, get_self(), [&] (auto& row){ //Update
row.cif = data;
});
}
}
[[eosio::action]]
void erase(name user,uint64_t id) {
require_auth (user);
cif_index cifrados (get_self(), get_self().value);
auto iterator = cifrados.find(id);
check(iterator != cifrados.end(), "Record does not exist");
cifrados.erase(iterator);
}
private:
struct [[eosio::table]] cifrados
{
uint64_t id;
std::string cif;
uint64_t primary_key() const { return id; }
};
using cif_index = eosio::multi_index<"cifs"_n,cifrados>;
};
Does someone know how to get the count? If not, it is possible to create an action in the Smart Contract to get the id of the last row? Thanks in advice