...by Daniel Szego
quote
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Saturday, July 7, 2018

Fabric composer tips and tricks - delete all data


If you want to delete all the data of a certain asset or participant category like in the case of a cleanup transaction, you have to do the following:

1. getting the asset or participant registry:

  const myAssetRegistry = await getAssetRegistry(namespace + 
    '.MyAsset'); 

2. querying the all elements of the given asset or participant registry:

  var allAssets = await myAssetRegistry.getAll();

3. delete all of the queried data:

  await myAssetRegistry.removeAll(allAssets);