Hi Antti. Any tip in how to achieve writing a new document inside a FB Collection taking the given userId key(UID). I’m trying to do this giving the path of the collection as you can see in the attached image. Considering that I am already getting the UID using the the data Slot UserID this would be possible, right? However nothing happens, when I save a new document, It behaves like there’s no /Users/$slot(‘ds_SlotuserID’) declare. Thank you. Best, Marcos
Guys. Still lost and walking in circles. What I am looking for is writing the document key with the same key given by UID of Firebase, to be able to associate it to Users collection where you already find a column with the same userID keys for each user. Data recorded when users finalize their registration (after authenticating with google) given them more information such as Address, Places, etc
Possible using React Studio Right? I suspect it is. If done, I can say that my project is not far from going to deploy. Thank you again
I’m not 100% sure but I think this happens because Studio does not know if you’re adding or editing existing or adding a new document. Unfortunately when you want to edit document you need to go to Edit screen through a list.
If you’re trying to create document with certain document name then unfortunately I think it is not possible at the moment. Currently document key is always automatically generated UUID.
Hi Annti. Thanks for your time. See, I’m already saving and editing a document just fine. Here’s how it works:
When you sign in using Google, automatically you have the userID, userName, userPhoto and userEmail. Great, For my app, I just need to confirm the last information which is the user current home address, including city and neighborhood. From a list of communities, first, you choose or search for your neighborhood and then you will be taken to another screen where you provide your addresses. Clicking “Finish” creates the user in the “Users” collection containing the necessary data that allows associating the user with the neighborhood key. Both collections bring the same ID. Thank you for your help. Best, Marcos
Ok then this looks quite simple and saving user information is already working on your end?
Yes, that’s right. Well, sounds great Antti. Let try this.
Hi Antti, I tried in many ways, but it didn’t work. I checked the link, but it was not clear to me how to do this. Any clues on how to make this script simple? Thanks a lot. Best
I tested this a bit and it’s not that simple to save the value from Data sheet to Data slot. This would need to be added into Screen state script and is so hacky that I don’t want to share it
I’d suggest you to edit the Firebase Login plugin so that it would load the users data from Firestore and then would save it to Data slot. I’d probably add this code into “saveCurrentUserDataInApp” function which get’s executed after the successful login.
P.S. This is my hacky solution which I added to screen’s State script. Note that you need to have at least two states and data slot selected from State setting to get the script written into exported code.
var user=this.props.appActions.getDataSheet(‘users’).items; //Get users data sheet
//If user is not undefined
var userFavCity=user[‘favoriteCityId’]; //get the favoriteCityId columns value into variable
this.props.appActions.dataSlots[‘ds_SlotFavoriteCityID’]=userFavCity; // save the value to data slot
Hey Antti. Thank you. Glad you share this. I’ve worked according to your hacky solution and the plugin as well but apparently something still missing. Best, Marcos
In the script you’re setting the data slot value to string ‘userNeighbourHoodsID’. I’m guessing you should have userNeighbourHoodsID variable there instead of the string. Just remove the ‘’ from the code. Anyway you need to debug the code from sources tab from developer tools to find out what is causing the problems.
Just a heads up on this matter.
We’re working for the solution for Firebase plugin which would allow user to set the Document name (via Document_key column) when creating a new document.
Hey Antti, that’s awesome! This feature is key for building complex apps and will turn React Studio even more powerful!
The upcoming version of Firebase plugin will also support Collection group queries. Which are pretty handy when you have nested data structures.
Great! that was my next question
Hi Antti. About the last Firebase Plugin update. Even after installing and restarting React Studio, every time you open it, it says that updates are available. Best.
Hi, thanks for notifying. The plugin package on live server was not the latest one (which caused the update notification to appear again and again). Now it should work and the lates plugin is live.
P.S. You can set the document name when adding a new document simply using the “Document_key” column. More info about the plugin update will come soon.
Great! I still trying. Today I spent some time trying to fix something that should be easy since I have the userId in all users documents and collections id which is saved within users document. Show the neighborhood that user belongs. I’m certainly missing something since the plugin update should handle this better, right? Here’s what I got.
Hi, you should not use document_key in query. It should not be used as field name in firebase because it is reserved to document name in Firebase plugin (plugin swaps document name into ). You probably want to use data slot Neighbour Id instead of document key?
# Hi Antti. I just tried this and apparently, the data slot is empty, right? I can fill the slots only if I click in a list containing the value. I am using the script you mentioned above and the screen data source is set to carry properties from datasheet “users” Thanks again
my new query is where(“NeighborhoodsID”, “==”, “$slot(‘ds_SlotNeighborhoodID’)”).orderBy(“userId”,“desc”)