How do you dynamically switch a Firebase ProjectBucket value?

This is just a POC program. The objective is to save some information in DonateDB bucket and then browse it.


The data base looks like this:
image
The Donate part works fine I see it in the list. I have two questions

  1. Now I want to browse the RequestBkt. One solution is to just duplicate what I do for DonateDB just replace it with RequestDB. That is not elegant, clumsy and clutters. So when BrwRequestBtn is pressed or as a matter of fact if there are 10 such FDB's depending on the Button pressed I want the FDB name to change programmatically. Then all I need is only one set of the block. How do I do it? Please help
  2. I have observed in the browsed output the order is always Donor1, Donor3, Donor2 even when I have more than that there is always a mix up. Is it expected way of reading back the FDB or it it a bug in my program. Thanks again.
  1. What is a POC ?
  2. Are the contents of the two buckets related? e.g. Donor1/Req1 ?
  3. Why not try storing each tag as a list, instead of a comma separated string? This may make it easier to handle in AI2 on return.
  4. You cannot rely on Firebase returning the data in order. You will need to sort on return.
  5. You refer to FDB - do you mean Firebase database ? Why would you need 10 databases ? Please demonstrate what you mean by switching between FDBs?
2 Likes

Thanks TIMAI2 here are the the clarifications. Sorry for the delay just got up.

  1. Proof of Concept, the objective of this program is to understand a concept
  2. The contents are not related,
  3. "as a list" Yes I thought so, but couple of video tutorials on List said to avoid it if possible and they are not stable. I will give that try. Thanks
  4. Got it, I can sort it later was just checking
  5. Yes FDB is FirebaseDataBase, sorry I should not have shortened it.
    10 was a random number I picked. For now I need only 3 FDB's, 10 was just a random number I picked for the futre. I have three Project buckets. The app is for needy people to make a Request for food(ReqDB), for restaurants and like to Donate excessive food (DonateDB) and there is UserIdDB which stores the user info. Each FDB might have thousands of entries. The app will connect one to the other.
    Switching of FDB: I will give a C language kind of explanation:
    Command line argument might be like app.exe DonateFood where app.exe is the application executable and DonateFood is the user input
    switch(UserInput) {
    case(DonateFood):
    XButtonClicked = DonateBtnClicked;
    XFDB = DonateDB;
    break;
    case(RequestFood):
    XButtonClicked = RequestBtnClicked;
    XFDB = RequestDB;
    break;
    ..................
    .....................
    }
    when(XButtonClicked is clicked) {
    use XFDB and do your work
    }
    So this variables starting with X are variables and can have values on what the user has requested. So in that way I dont have to repeat the blocks. Just one logical block and I make the decision before entering the block. My assumption is MIT app might have that kind of feature.

Thanks again I will start working on your advice

I am still slightly confused as to why you need to use three different firebase projects? You should be able to just use one (as you have shown in your console image)? (Or do you mean three different projectBuckets ?)

Sorry I mean ProjectBuckets my mistake for using wrong nomenclature. Apologies

:smiley:

In which case, AI2 provides the blocks to be able to set different projectBuckets at runtime, in order to access different parts of the Firebase database. You can automate this to a degree...

1 Like

Cool thanks. So it is possible. Let me Google for that and check out some example. Thank you very much

A simple example

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.