Is there a way to apply some custom filter while fetching data from the stream?

+1 vote

Hello Team,

I'm looking for the solution to get data from the stream based on some custom filters.

Since I have a transaction stream where I save the details of each wallet transfer along with some metadata.

Here I am using transaction hex as key in the stream.

Following information I'm storing into transaction metadata:
1) user-email
2) transaction type (credit/debit)
3) amount
4) timestamp

Now when I use the liststreamitems command it will return all available transactions from the stream.

I want some custom filters to fetch data based on specific user email or if metadata contains a transaction type of "Credit / Debit" only then the transaction should return from the stream.

So is there any way to apply such criteria when getting records from the stream?

asked Jun 4, 2021 by Nikunj Dhameliya

1 Answer

0 votes
Best answer

There are a couple of approaches to doing this:

  • When writing the stream items, use additional keys to represent the additional ways in which you will want to retrieve the items, e.g. email and transaction type. (Each item can have multiple keys.)
  • Use MultiChain Enterprise to feed the stream data in real-time to an external database, which you can then index and retrieve however you like.
answered Jun 4, 2021 by MultiChain
selected Mar 8, 2022 by Nikunj Dhameliya