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,040 points
182 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 65,820 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,030 points
151 views
0 votes
1 answer
+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
207 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
• 65,820 points
28 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
• 65,820 points
29 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.