Key and subkey in publishing stream items

+1 vote
Hello,

i have 2 questions plz.

first question: Can I retrieve the stream items without using key? or txid?

Second question:

I want to use key to retrieve the data from stream, can I use two keys, like key and subkey due to my data architecture. for example

the key is the name “John” , there 3 subkeys

key 1 is called education

key 2 is called address

key 3 is called studentInfo

to make the structure like normal database.

is it possible, or there is different way to implement it.
asked Feb 18, 2022 by musharraf90

1 Answer

+2 votes
 
Best answer

1. There are a bunch of different ways to get information out of streams, including liststreamitems – see the 'Querying subscribed streams' sections of the API page: https://www.multichain.com/developers/json-rpc-api/

2. Yes, you can have multiple keys on a stream item, it's not a problem, just pass an array instead of a string in the appropriate publish API. You can also use the liststreamqueryitems API to query items with multiple keys, but beware that it may be inefficient – it will choose the best individual key to use, but then has to scan all items with that key to check for the other keys. You might want to think how to use keys better to prevent that.

answered Feb 18, 2022 by MultiChain
selected Feb 18, 2022 by musharraf90
Thanks a lot
...