Practical notes on Enterprise software systems and the economics of software.
...by Daniel Szego
"On a long enough timeline we will all become Satoshi Nakamoto.."
|
|
Daniel Szego
|
Monday, November 12, 2018
Fabric composer tips and tricks - deleting asset from array
If you want to delete an element from an asset or participant that as a reference array to another asset or participant, the process is pretty similar to deleting an element from a javascript array:
1. Getting a registry for the asset or participant
const assetReg = await getAssetRegistry(namespace + '.Asset');
2. Getting an index of the asset or participant to be deleted
var index = asset.arrayOfReferences.indexOf(assetToBeDeleted);
3. Delete the index in a javascript style
if (index > -1) {
asset.arrayOfReferences.splice(index, 1);
}
4. Update the asset
assetReg.update(asset);