I'm developing a cart and orders screens in a marketplace application using firebase realtime database.
My order Structure:
what I want here is retrieving all orders from all users based on its status! and is it a good structure ?
I'm developing a cart and orders screens in a marketplace application using firebase realtime database.
My order Structure:
what I want here is retrieving all orders from all users based on its status! and is it a good structure ?
I solved this problem by changing the structure of orders:
I remove the node of userId that came next : orders/uid
order structure become orders/order_id/userId
I change order security rules to:
"Orders":{
".read" : true,
"$id":{
".write" : "newData.child('userId').val() === auth.uid",
".read" : "root.child('Orders').child($id).child('userId').val() === auth.uid",
}
}
Now I can query what I want by the methods orderByChild() and equalTo()