Is there a way to query Multichain blockchain data from within Multichain-Web-Demo?

+1 vote

Thank you very much for your prompt responses to our questions.

I've been able to set up a stream and publish data using the CLI and MC web-demo. I've also been able to view the data using MC Explorer-2.

I want to take it a step further and query the published data using some key/value from any of the key-value pairs. Is there a simple way to do that without resorting to MC Enterprise and an external database?

Here is a sample JSON data I have in MC Web-Demo.

Key:              Jemo1_Bldg4_25 

JSON Data:       { "RegID": "315", "RegName": "Abebe Kebede", "RegDate": "12-Apr-2007", "LottoRound": "12", "GazetteDate": "15-Sept-2019", "LottoNo": "764392", "TransferDate": "30-Nov-2020", "Remarks": " " }

Want to query, for example, using "RegID" or "LottoRound".

Any and all help is greatly appreciated as always.

Thank you.

Fesseha 

asked Apr 4 by Fesseha

1 Answer

0 votes

Using MultiChain on its own, you can only query data by the stream key (I think in your case, Jemo1_Bldg4_25). For more complex querying within the JSON structure you would indeed need to use an external database. However please note that you can have more than one key per stream item, so you're welcome to use extra keys to help with more dimensions of querying. For example for this item, you could have used the keys RegID_315 and LottoRound_12 as well as Jemo1_Bldg4_25.

answered Apr 4 by MultiChain
Thank you for the quick response.
I didn't quite get the extra key solution for my use-case.
"Jemo1_Bldg4_25" (on Jemo1 Building, Floor 4 and House Number 25) is one of hundreds of thousands of apartment housing units in a populous city that's to be transferred to a lucky city resident who has been registered for a public-funded low-cost housing scheme.
Houses are transferred -- as houses are ready for habitation after construction -- in successive rounds of lottery draws (thus LottoRound) among registrants. Each lottery result has a unique number (LottoNo).
RegID is the registration number of an eligible city resident for the low-cost housing scheme.
The whole idea is to put the registration data, lottery draw results, and house transfer date on blockchain in a transparent way to build trust between the city government and its constituents.
Residents may want to query the database by RegID, LottoRound, or RegName. I don't see how putting any of these attributes as keys would help in querying because the data, I think, needs to be organized in such a way that there is one housing unit and under it there are different attributes, such as the ones listed above.
Thank you again for your help.
Fesseha
You can duplicate the RegID and LottoRound information, both in a stream item key and in the JSON payload. The stream item key enables easy querying, and the JSON payload is there to have the data in a comfortable form.
Appreciate it, thank you for letting me know of a different approach to getting the work done.
...