Hyperledger Composer Query using relation

0 votes

I have made a query in Hyperledger Composer where in the query tries to search for all invoices of a borrower. The borrower is a participant of the invoice asset:

asset Invoice identified by invoiceId {
  o String invoiceId
  o String invoiceRef optional
  o DateTime dateCreated
  o String type
  o DateTime invoiceOrPurchaseDate optional
  o Double amount
  o DateTime invoiceDueDate optional
  o String paymentStatus optional
  o Boolean overdue
  o Double outstandingBalance
  --> Participant borrower
  --> Participant lender
}

I need a query that will return all invoices of a borrower and I did this in Hyperledger composer by coding below:

query QInvoiceByBorrower {
    description: "Select invoice by borrower"
    statement:
        SELECT org.n.blockchaindemo.Invoice
            WHERE (_$borrower == borrower)
}

But when I try to call the query through REST API, I get [] empty result as below:

http://10.10.4.244:3000/api/queries/QInvoiceByBorrower?borrower=resource:org.n.blockchaindemo.User#1381991

May I know how to create a query that will search using a foreign relation in Hyperledger Composer?

Nov 5, 2018 in Blockchain by slayer
• 29,370 points
928 views

1 answer to this question.

0 votes

 you need to refer to your specific Participant type i.e. User rather that the system type Participant. So the last part of your Invoice will be:

  o Double outstandingBalance
  --> User borrower
  --> User lender
 }
answered Nov 5, 2018 by Omkar
• 69,230 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
1 answer

Issue deploying the business network using hyperledger composer

I had same issue. I created card ...READ MORE

answered Jun 5, 2018 in Blockchain by Johnathon
• 9,090 points
951 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,399 views
+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
1,088 views
+1 vote
1 answer
0 votes
1 answer

Hyperledger Composer: How to query using string?

You can try this: query selectReading { ...READ MORE

answered Nov 9, 2018 in Blockchain by Omkar
• 69,230 points
481 views
0 votes
1 answer

Cant query in Hyperledger Composer

There's a mistake in your WHERE statement. ...READ MORE

answered Oct 26, 2018 in Blockchain by Omkar
• 69,230 points
739 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP