0

I have the following structure in my database: enter image description here

var pathFriend = "stuff/"+ userKey;                    
admin.database().ref(pathFriend).orderByChild("sale").equalTo(true).once("value", function(snapshotItem) {
                            snapshotItem.forEach(function(data) {
                                console.log("key = "+ data.key);
                            });
                    });

The question is how can I search by two fields with boolean values? Thanks.

Community
  • 1
  • 1
Konstantin Konopko
  • 5,229
  • 4
  • 36
  • 62
  • 1
    You can't search by multiple fields with Realtime Database. You can with Firestore. – Doug Stevenson Jan 19 '18 at 18:19
  • @DougStevenson is it make sense to migrate to Firestore? Is it an easy thing? – Konstantin Konopko Jan 19 '18 at 18:22
  • 1
    That depends entirely on your situation. Firestore is going to be preferred in the future, so it's worth looking into. – Doug Stevenson Jan 19 '18 at 18:30
  • 1
    Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For an example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jan 20 '18 at 01:53

0 Answers0