Hyperledger: How to update values from an asset?

0 votes

I want to find the rider_id and update parcel_id in the following. 

model

asset Route identified by route_id {
  o String route_id
  o String rider_id
  o String parcel_id
}
transaction assignParcelToRider {
  o String rider_id
  o String parcel_id
}

logic.js

var assetRegistry;
var id = assignValue.rider_id;
return getAssetRegistry('org.rytle.Route').then(function(ar) {
    assetRegistry = ar;
    return assetRegistry.get(id);
}).then(function(asset) {
    asset.parcel_id = assignValue.parcel_id;
    return assetRegistry.update(asset);
});

Here I want to find the rider_id and update parcel_id there. But here its not finding t

model

asset Route identified by route_id {
  o String route_id
  o String rider_id
  o String parcel_id
}
transaction assignParcelToRider {
  o String rider_id
  o String parcel_id
}

logic.js

var assetRegistry;
var id = assignValue.rider_id;
return getAssetRegistry('org.rytle.Route').then(function(ar) {
    assetRegistry = ar;
    return assetRegistry.get(id);
}).then(function(asset) {
    asset.parcel_id = assignValue.parcel_id;
    return assetRegistry.update(asset);
});

Nov 6, 2018 in Blockchain by digger
• 27,630 points
273 views

1 answer to this question.

0 votes

This should work:

return getAssetRegistry('org.rytle.Route').then(function(ar) {
      return ar.get(route_id)   // or whatever you've assigned it to or txnobject.route.getIdentifier());   // ie you must get the asset by identifier
      }).then(function(asset) {
           asset.parcel_id = id;   
           return ar.update(asset);
       });                  
answered Nov 6, 2018 by Omkar
• 67,290 points

Related Questions In Blockchain

0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,010 points
44 views
+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,010 points
769 views
0 votes
1 answer

How to retrieve data from an Ethereum Block?

To get transaction details like Block Hash ...READ MORE

answered Jul 19, 2018 in Blockchain by Perry
• 17,010 points
37 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
265 views
+1 vote
1 answer
0 votes
1 answer

How to read the ETH value and other token values from an account?

You can do this eth.accounts shows you all known ...READ MORE

answered Oct 22, 2018 in Blockchain by Omkar
• 67,290 points
26 views
0 votes
1 answer

Hyperledger Fabric 1.0 how to maintain privacy from OSNs?

Yes, OSNs can see all the transaction ...READ MORE

answered Jul 2, 2018 in Blockchain by Omkar
• 67,290 points
28 views