Firebase query for multiple where condition

前端 未结 1 1027
眼角桃花
眼角桃花 2020-12-22 07:15

I need equivalent query of

SELECT PlayerName FROM GameScores WHERE Department = \'HR\' OR Department = \'IT\' OR Department = \'Marketing\'

相关标签:
1条回答
  • The only way to filter a property on multiple values in Firebase is if those values are in a range. For example, you could get all items matching your values with:

    ref.child("GameScores")
       .orderByChild("Department")
       .startAt("HR")
       .endAt("Marketing")
    

    The problem with this is that it also matches scores from other departments whose name is between HR and Marketing, such as

    There is no way in either the Firebase Realtime Database or Cloud Firestore to pass multiple separate values into a query. You will have to execute a separate query for each value and merge them client-side.

    Also see:

    • firebase equivalent to sql where in ()
    0 讨论(0)
提交回复
热议问题