How to find whether the transaction already exist

2019-06-14 13:46发布

问题:

Participant 
IDFC 

Participant
TATA , MRF 

Asset
FINANCEPROGRAM 

Transaction
(Data need to submit)
participant(TATA) ,Asset (FINANCEPROGRAM ) ,loanAmount , loantenure

I need to check whether the transaction for FINANCEPROGRAM and TATA are already exist.

If so exist i need to reject the transaction.

var query1 = query('SELECT com.ett.blockchain.Programmeben WHERE (beneficiary == _$beneficiary AND bankprogramme == _$bank program) ');

 return  query('query1',{beneficiary : 'resource:com.ett.blockchain.Beneficiary #'+pgben.beneficiary .customerid,bankprogram: 'resource:com.ett.blockchain.Bankprogramme#'+pgben.bankprogramme.programmeid})

  .then(function (transactions1) {

   transactions1.forEach(function (trans1) {    

       console.log("transaction exist " );

        });

    throw Error("Transaction already exist");

});

回答1:

you are missing a buildQuery statement.

eg

var query1 = buildQuery('SELECT com.ett.blockchain.Programmeben WHERE (beneficiary == _$beneficiary AND bankprogramme == _$bank program) ');

return query(query1, { beneficiary : 'resource:com.ett.blockchain.Beneficiary#' + pgben.beneficiary.customerid, bankprogram: 'resource:com.ett.blockchain.Bankprogramme#' + pgben.bankprogramme.programmeid } )

See examples here (specifically, the 'Javascript code js' section) -> Why are the following added assets not persisted in the hyperledger registry?