Avoid duplicate keys in a stream

+1 vote
Hi,

I am inserting huge data to my multichain streams and I understand that data with same key will be stored to multichain with versioning.

I would like to know how can i avoid inserting duplicate records to the stream , how can i check if a key already exists.

Let me know how this can be done, thanks.!
asked Dec 16, 2018 by blkchain_enthu

2 Answers

+1 vote

You can put up a check where you are taking inputs from user for the key parameter, for checking if the key already exists or not by using liststreamkeys api command to retrieve the names of the keys that are already stored on your chain.

answered Dec 17, 2018 by gimmick
0 votes

Apart from avoiding duplicate keys, you can also just decide to only retrieve the first item for each key, using liststreamkeyitems with the appropriate parameters.

answered Dec 18, 2018 by MultiChain
...