我想在 Hyperledger Composer 中创建供应商列表和单个订单之间的关系

I want to create a relationship between list of suppliers and a single order in Hyperledger Composer

我有一个交易下单,它将供应商列表作为输入并创建订单。

transaction PlaceOrder 

    {
        o String orderId
        --> Consumer consumer
        o OrderDetails orderDetails
        --> Supplier[] supplier
        --> Commodity commodity
    }

订单是具有供应商列表的资产

asset Order identified by orderId {
    o String orderId
    o String orderName optional
    o OrderState state
    o OrderDetails orderDetails
    --> SupplyOrder[] supplyOrder
    --> Trader owner 
    --> Commodity commodity
    --> Consumer consumer
    --> Supplier[] supplier
    o Rating rating optional
}

此订单是在调用 placeOrder 事务时创建的,应该在供应商列表之间创建关系。

对于我使用的单个供应商

order.supplier = factory.newRelationship(namespace, 'Supplier', placedOrder.supplier.getIdentifier());

但是上面的代码对于供应商列表是失败的。

有两件事可能会有所帮助

  1. 当您编写 "This order is created when placeOrder transaction is called " 时,您的交易实际上是否调用了 'placedOrder'(在您的代码中)(只是为了检查,很可能是)。

  2. 因为您已经定义了一系列与 Supplier 的关系,所以“工厂”语句可能应该是:

     order.supplier = factory.newRelationship(namespace, 'Supplier', placedOrder.supplier[0].getIdentifier());