You can't do this with Firebase Realtime database without some significant changes in your database structure. Realtime Database doesn't have the capability to perform filtering on multiple conditions (in SQL terms, "multiple where clauses"). If you want to check for matches on multiple properties like fromID1
and toID
, you'll have to create a composite field that contains a combination of those two properties. For instance, you'll need a String value that has fromID1
and toID
concatenated together like this:
fromID1_toID
You can also take a look at my answer from this post.
Note, if you'll later decide to to change your database to Firestore, please note that this feature is available, you can filter on multiple conditions.