Hyperledger: How to retrieve properties of relationship through query?

0 votes

I want to create a query which returns all the Requests (asset) in which the Container's (asset) owner's id is equal to the parameter.

Model file (owner of a container is a Company participant, identified by id):

namespace org.acme.shipping.assets
import org.acme.shipping.participants.*

asset Container identified by number {
  o String number
  o ContainerType type
  o String content
  o ContainerStatus status default = "FREE"
  --> Company owner
}

enum ContainerType {
  o DRY
  o REEFER
}

enum ContainerStatus {
  o LOCKED
  o FREE
}

asset Request identified by id {
  o String id
  --> Container container
}

Query file

query getRequestsByCompany {
  description: "Get requests by company"
  statement:
      SELECT org.acme.shipping.assets.Request
          WHERE (container.owner.id == _$company_id)
}

How do i do this?

Nov 8, 2018 in Blockchain by slayer
• 29,050 points
87 views

1 answer to this question.

0 votes

I dont think its possible using query. You can do it using loopback filters:

{"where":{"shipmentId":1000}, "include":"resolve"}
answered Nov 8, 2018 by Omkar
• 67,480 points

Related Questions In Blockchain

0 votes
1 answer

How to retrieve complete world state of hyperledger?

you can achieve this by iteration process ...READ MORE

answered Jul 5, 2018 in Blockchain by slayer
• 29,050 points
277 views
0 votes
1 answer

How to connect two instances of Hyperledger Fabric?

Before getting on with your question, let ...READ MORE

answered Jun 11, 2018 in Blockchain by Christine
• 15,790 points
70 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,550 points
68 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
141 views
0 votes
1 answer

Hyperledger Composer: How to retrieve array of assets?

This is what worked for me: asset Ask ...READ MORE

answered Nov 14, 2018 in Blockchain by Omkar
• 67,480 points
390 views
0 votes
1 answer

Hyperledger composer: How to include relationship in custom query?

You are trying to use filter={"include":"resolve"} in Composer Query. ...READ MORE

answered Nov 16, 2018 in Blockchain by Omkar
• 67,480 points
365 views