Load single Firestore document into Data sheet

Hi. I followed the example below, and noticed something peculiar.

https://reactstudio.medium.com/load-single-firestore-document-into-data-sheet-1880e4edcccd

If I put in a default value for the data slot (Eg. for ds_selectedRestaurantId in the example), I can reload the data sheet manually and get the correct row.

However, during actual code runtime, I only retrieve a row if the data slot has the value of the very first row in the Firestore database. Any other valid values from other rows in the DB, nothing gets returned.

Wondering if there is a bug in the code somewhere. It’s as if there’s a “limit 1” added somewhere deep in the code which happens to retrieve only the top row in my DB as the input of all this. But I have searched my own code and there is no “limit 1”

I have confirmed backward and forward that the value of the data slot gets updated and is correct because I did a console.log on the data slot.

I even tried enabling the option of “Update based on data slot” in the data sheet, and added a script to do another console.log. I could see every single time the data slot was updated, that my console.log fired. Yet the data sheet only returned a row during runtime if data slot contains the corresponding value in the first row in the DB.

Pretty baffled.

Well, I ended up going with a different approach. I used the Firestore docs from Google to retrieve a single row instead of using a special datasheet.

Hi, was just using the “load single document” into Data sheet and it works well on my project. Is it possible that you have something (maybe a blank space) in the Query text field? In the plugin code the code checks if the query has something in it and runs the query if has a value.

Thanks for the response, Antti. I looked just now and there is nothing in the query field.

I did manage to move on with a script which involves more code but provides finer grain control. Including the ability to update a row whereas the existing datasheet implementation creates a new row everytime even if all the data field values are identical. I think I saw in another thread that the firestore plug-in would need to be modified in order to “update” a row. I tried modifying the plug-in briefly but didn’t have any luck.

In any case, there was another previous thread in this forum that touched on the issue. It had more to do with updating a document with existing value - also based on the Google Firestore reference. There was a minor typo in the code in that thread. I went and commented on that thread with more info just now.

Related thread: