Data retrieval capabilities

+1 vote
Hi All,

I'm trying to find what are the ways of data retrieval supported in multichain.

I would like to know if there is new capability in MC 2 which supports data retrieval using part of a key or part of data.

Example: Key is Multichain

Search with something like key:*chain* should return this particular record.

Thanks.
asked Jan 2, 2019 by blkchain_enthu

1 Answer

0 votes

I'm afraid wildcards in keys are still not allowed when retrieving items in MultiChain 2.0.

However stream items can now be given multiple keys, so if you know ahead of time what sort of wildcards might be used, you can add these are multiple keys, e.g.:

multichain
multi*
*chain

Then you can retrieve the item with any of those three patterns.

answered Jan 3, 2019 by MultiChain
" stream items can now be given multiple keys "

wait so, one particular stream item can now have multiple keys ? can you explain any probably use-case for such a facility ?
Yes, if a piece of data is to be categorized in multiple ways for subsquent retrieval using liststreamkeyitems. For example, employees could be categorized by department or geography.
ah right ... the good old SQL days.

so what if we want each item to remain unique in a particular data stream?

how do you propose we go about it then ?

can we choose to disable this "multiple keys for a single item" functionality in certain data streams ?
You can't enforce key uniqueness in a stream at write time. But you can simply only pay attention to the first item for each key at retrieval time, which achieves a similar effect.

To disable multiple keys for a stream item, you can use a stream filter. Here's some example code to get started: https://github.com/MultiChain/smart-filter-examples/blob/master/stream-filters/restrict-key-count.js
...