问题
I'm new to react-native and firebase, and I am building an app. I stumble upon a problem using "array" in firebase (i know that firebase doesn't work with array), but I want to know if there is some way to retrieve this data.
This is the data I have in the server, and I want to get all the purchases that have the product "id" (in red)
I tried to use the code below and some variants but no success, returns null
firebase.database().ref('purchases').orderByChild("products/id")
.equalTo("-Lgida0VKuZZ6V7K0LkH").on('value', function (rawPurchases)
I want to know if there is a way to get this information.
Thanks.
回答1:
var scoresRef = firebase.database().ref("purchases");
scoresRef.orderByChild("products").on("value", function(snapshot) {
snapshot.forEach(function(data) {
console.log("The " + data.id + " data is " + data.val());
});
});
try this method and review more here
来源:https://stackoverflow.com/questions/56659730/querying-array-from-firebase-react-native