Change Firebase query based on Selector target

Hi, how can I map the selector index to string for a Firebase query?
My selector has 3 tabs: Top (0), Trending (1), Potential (2).
The selector’s target index is saved to ds_selected_tab.
My Firebase query looks like this: where(“state”, “==”, “$slot(‘ds_selected_tab’)”).

  1. Selector “selected state” index could not be set to string.
  2. “Transform value using script” saved the result to options.servicePath, which does not get used in dataSheet.expandSlotTemplateString.

Thanks for this great tool. I am checking how far I can go with this without coding for an MVP.

Screen Shot 2022-03-19 at 5.18.03 PM

This workaround “Transform value using script” works but a little awkward because:

  1. Transformed value modifies servicePath, which is used as the collection_id, rather than the query variable.
  2. Need for manually changing: this.dataSlots.
    let tab_index = input;
    let selected_list;
    switch (tab_index) {
      case "1":
    	selected_list = "trending";
        break;
      case "2":
    	selected_list = "potential";
        break;
    //	case 0:
      default:
      	selected_list = "top";
    }
    this.dataSlots['ds_selected_tab'] = selected_list;
    return "keyword_details";

Hi and thanks for testing React Studio!

I tested to create similar kind of app and I had no problem querying collection with data slot value containing the “selected index”. I didn’t need to cast the value to string at any point.

Thank you for your reply @Antti_Neonto. Sure, if my document stored the “selector tab index” it would work, but in my case, the field of the document is one of ["trending", "potential", "top"], so I needed a place to map these values to the corresponding “selector tab index” [0, 1, 2].

The Firestore plugin UI looks like “Edit script” would allow modifying the dataslot for query, but it is actually modifying the collection ID. I guess this is because you needed custom scripts for complex nested collection paths.

I guess the Query functionality in the Firestore plugin is basic. As I needed to Query 2 fields, I ended up storing the whole query in a dataslot. ex) where("isactive", "==", "true").where("type", "==", "top")

I hope this helps someone, and with more Firestore users, the plugin can be improved.