Button saving more info than requested in Firestore

Hello,

I have been dealing with this for several hours and I am not sure if it is me doing something wrong or that RS has this bug.

I have a component that has a lot of info or props carried from a collection called ‘preloads’, which is the one that is populated with this component. I have placed a button in this component that I want to be used to save data in a different collection. Specifically I am looking to save the date when this button is clicked, and maybe the name of the document in the original collection.

I have established everything fine. The ‘users’ dataSheet where the info is to be saved. The button inside the document with the action “Save data” and the information that I want to be saved:

As you can see in the screenshot, I have left blank the fields that I don’t want to be “touched” and added the script to save the field “date”. However, if I select the option “Update”, it won’t do anything. The most surprising behaviour for me is that if I select “Auto”, it will add all of the document information (props of the component) in the ‘users’ collection even though I haven’t pointed that to happen.

That takes me to an old problem that I have had before. I believe that the “Update” option in the Save Data interaction for Firebase doesn’t work well. That option should just update the field that is pointed in RS, but it doesn’t seem to do anything unless I am doing something wrong.

Thank you.

You’re right the “update” mode doesn’t work. The admin team has confirmed in previous threads that the “update” functionality was not actually implemented.

It sounds like at the very least you’re able to save the data. To have fine-grain control over what to save or not save to Firestore, you would have to use a script to do that yourself.

See Multiple-step Saving Process? (Or updating an existing entry?)

1 Like

Thank you so much for your answer! Having that information I can keep digging about the approach and know that I must achieve it with a script. I will try again tomorrow and let you know. Thanks!

1 Like

I can confirm. This had been a mystery to me until I just learned to live with it. LOL

Definitely this is a bug. It happens to me several times. To get rid of it, I started using the script and writing myself the set, update, or delete script. If you are using Cloud Firestore, this is very easy. See, sometimes a bug is a good thing :). It turns out that this has forced me to learn. :bulb:

Indeed @Marcos_Alencar! I am learning how to write simple JS scripts at the same time my project keep growing and I need to incorporate new things.

The next thing that I want to explore is how to add fields to an array (existent or not) in a given document in Firestore with a script. I believe I know what the approach is but if you know how to do it I would really appreciate the guidance :slight_smile: