Search code examples
hyperledger-fabrichyperledgerhyperledger-composeribm-blockchain

Retrieving properties of relationship through query


I would like 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)
}

However, the current query does not seem to work. Is this achievable with a query?


Solution

  • I did a lot of research also to do it using query file, but couldnt find a way, so I think that its not possible at moment.

    The alternative way is to use loopback filters:

    Something like:

    {"where":{"shipmentId":1000}, "include":"resolve"}