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
• 26,740 points
1,580 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
• 69,220 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,100 points
713 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,100 points
2,956 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,100 points
2,704 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+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
1,127 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
• 69,220 points
852 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
• 69,220 points
865 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP