this is my table

  struct [[eosio::table]] payment_made
    uint64_t pay_id;
    uint64_t loan_id;
    uint64_t pay_amunt;

    time_point_sec pay_date_req;
    time_point_sec pay_date_approve;

    bool payment_status= false;
    // name pay_from;

    uint64_t primary_key() const
      return pay_id;

     uint64_t by_loanId() const
      return loan_id;
 typedef eosio::multi_index<"paymentmade"_n, payment_made,    
                       indexed_by<"loanid"_n, const_mem_fun<payment_made, uint64_t, &payment_made::by_loanId>>>paymentmade;

 paymentmade paymade_table;

Here my loan_id is Secondary multi-indexed key

Here i want to modify my table,for that i will need the private key of the table so,i want to get the private key of table with the help of secondary key please help?

I want to modify
pay_date_approve and payment_status in this function and the only argument is getting passed is loan_id which secondary key of the table
,so can we do this ?

void mainloan::payconfirm(uint64_t loan_id)

 auto pridx = paymade_table.get_index<N(loanid)>();
  • What do you mean "modify the table"? Are you trying to insert a record? Update a record that is already in the table? Oct 25, 2019 at 13:54

1 Answer 1


Do same like primary key index:

void mainloan::payconfirm(uint64_t loan_id) {
  // assume paymade_table is instantiated through contract constructor
  auto pridx = paymade_table.get_index<N(loanid)>();
  auto itr = pridx.find( SECONDARY_KEY_WHICH_YOU_WANT_TO_FIND );
  pridx.modify(itr, same_payer, [&](auto& p) {
    /* updater */
  • pridx.modify(itr,_self, [&](auto& p) { /* updater */ }); Nov 8, 2019 at 6:22
  • @guruprakashgupta You're right. I updated example.
    – conr2d
    Nov 8, 2019 at 7:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.