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?