0

I have a simple global public transactions collection, similar to Ethereum/Etherscan.

/Transactions -> tx1 
              -> tx2

Tx document looks like this

{
  timestamp,
  from: username1,
  to: username2,
  amount
}

Now I would like to query all the Tx documents where username is equal to from OR to and order by timestamp.

Is this natively possible in Firestore?

If not do I have to create separate transaction collections for all the users along with the global one? And then do I need to add 3 documents - global, user1 and user2 transaction collections when user1 sends a transaction to user2 ?

Or is there a better approach?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • It's not possible using multiple fields. You can always perform multiple queries, one for eacah field, and merge the results in your app. Or you can combine the fields into a new array field and use an `in` query to look for both values. – Doug Stevenson Dec 16 '22 at 22:40

0 Answers0