Hey everyone, I hope you are doing good!
I feel really glad to be back here after a very long time
I am developing a project in which this time I’ve chosen Firebase as my main database (this is my first time working with firebase). In this project, I mainly have two things I need to store - stores & their orders. So I needed a data structure format that would make it easy for me to retrieve any order data easily.
I’ve come up with a database format idea that looks like this :
Let me explain the whole workflow. When someone posts an Order, the Order ID becomes a sub-bucket key, and the order’s details are that sub-buckets’ items. Ultimately, the order gets stored as a sub-bucket under the main bucket of the store.
Now, since it’s my first time using Firebase, I am kind of confused with creating a new sub-bucket (with items in it) under a main bucket of the Store, and how to retrieve any Order’s (sub-bucket’s) details later. I’ve so far tried many combinations of blocks I could possibly think of, and it doesn’t seem to work out. Can you please guide me?
Thanks a lot, @muneer! Really appreciate your help. I will surely try this out ASAP.
Just a quick doubt, do I need to initialize any cloud variable or just grab and add name of the bucket in front of it? Just to know, I have my Firebase connected to my app.
Initializing a cloud variable can result in overwriting the contents of the Firebase bucket.
When dealing with Firebase, always use the variables listed at the bottom of the variables drawer. Those do not require initializing and the text part of the variable refers directly to the key in Firebase.
For storing data under a sub-bucket (inside a main bucket), I used this command : (the / was inspired from your given blocks )
Also, for the items in the sub-bucket, I used a create object block which includes all the keys and values of the order details. I can now finally store in the format I desired
For retrieving data, I used the method you gave : (textbox1 being store id & textbox2 being order id)
This whole thing worked like a charm. Huge thanks to you for helping me out!