Firebase firestore - write data to firestore

Dear Appgyver Team,

is the new standard firebase connector only meant to read data? In your Tutorial Google Firebase connector - Composer you show how to connect with a read access. But I would also like to write back into a collection.

Do I need to do a “manual” REST API integration for this or can I also leverage you “connector” which makes Auth and also read access super easy :slight_smile:

Many thanks
Jens

Hi, you can use the Create/Update/Delete record flows as you would with a data resource setup with a REST API integration. There isn’t yet a tutorial on the topic, but I posted some short examples on how to create/update records here.

1 Like

Great! I will try that! This seems just to be too simple! This connector is really awesome! :slight_smile: :slight_smile:

Hello, am able to write data over to firestore fine, but all the numbers are written as strings. Also, I’d like the date/time texts to go as date/time type into firestore.

Is this a bug (in case of the numbers)?

Are you able to point me out any documentation on how you map the data types between firestore and the data connector config? (I am able to workaround the number part by using NUMBER() function, but not with the date/time - any help here will be appreciated).

to do that, you have to set your variables according so that it recognizes what type of data it is

The data types I mentioned are all set as per my comments. That’s the issue.

i would try to make some changes on the problematic fields in firebase, so that you choose what type of data is in each field and then go on appgyvers data connector and make a test request on the problematic connection and then set the schema based on the response.
I think it will work that way

When creating a data resource which is connected to Firestore, you have to specify a data schema. In Apgyver you can specify what type of data has to be stored as what type. (You can modify it later as well in the “Data” menu.)

Important to note that, Firestore also has its own data types. So to utilize, I would read up on Firestore docs and try to minimize the different data types. In case of numbers and strings, I would simply go with the string type. And convert the data to the specific type when needed. Also the date type is different in Firestore as there it is “timestamp” (as a Google usual use case needs timestamps) and not exactly a date, I would store that as well as a string.

Firestore docs: Data types for Firestore

Remember Firestore is a NoSQL (doc model, hence no schema) db. You can’t specify a schema (and you shouldn’t in practice).
I will post some screenshots soon, hopefully that might help you to understand the issue am facing.

1 Like

Yes, I have specified the right data type on Appgyver, as per the app needs. I am very aware that Firestore has it’s own data types and the issue is indeed clearly about types mismatch when Appgyver operates via “Create Record” flow function (as part of Firestore connector).

At the moment I only need numbers and date/time data types - there is no point in talking about strings because we know now that it works. Converting it back and forth is painful. It shouldn’t be this way if Appgyver really wants to support Firestore. I’m hoping someone from Appgyver to confirm this limitation, and also some roadmap as to when a fix will be put, if that’s possible.

Thanks for your input.

1 Like

Just adding the screenshot of Firestore’s API documentation that shows all Appgyver needs to do is to send the value qualified as a timestamp. This seems to work when I use NUMBER() function on the number, but didn’t work when I used TIMESTAMP() on the date/time field.

Youre right about the nosql point but to tell you the truth im not using the number function and my data are stored correctly, just by defying the variable type. I dont know why it doesnt work for you

What do you mean by defying the variable type? Isn’t that an issue?
Simply, if it’s a number in Appgyver, then it needs to be a number in Firestore. If it’s date/time in Appgyver then it needs to be a date/time in Firestore.

yeah im talking about this which you said youve done
image

one last thing that could help, is to show us your update record function maybe theres something going on there

I managed to workaround the above issue with workarounds. For number using NUMBER() works. For date/time type, I marked it as a number and used DATETIME() and TIMESTAMP() to convert back and forth between datetime and epoch milliseconds.

I have, however, hit couple more bugs. First one - basically in my data variable that’s pulling in from Firestore data resource, am applying filtering and sorting. The issue is that if I sort it DESC based on a number field (the same datetime field in the earlier issue that’s now converted), it blows up and no data records are pulled. If I leave it on ASC - it’s working fine. Please help.

Second one - Delete record flow function doesn’t work from within a card. It only has one property (another one that said Identifier, which was marked obsolete, came with a message asking for me to delete it). This property is called Resource Name and it’s also got some warning. See attached.


Hey, I am getting the same error, numbers are passed as strings in firebase. Any help would be appreciated