I am writing something to insert documents in to a collection in Firestore. As documents where inserted I noticed that a duplicate document id didn't fail, but updated the record.
I referenced, Firebase / Firestore Integration, and noticed that at one time Retool had a
set option, which isn't there any longer, so I wondered if the
insert document is actually using a set against Firebase. If a set is being used, to confirm, the
merge option is set to false (default).
I know it may sound strange, but I was hoping that the insert action actually did an insert against the collection as it would alert us of a duplicate document id.
Hey @brettski! Good to hear from you again
So re: the docs - we do have a
.set option for the Realtime Database, but not for Firestore (I don't believe this was ever supported). The Node SDK for Firestore does support this, but we don't have an option in Retool quite yet.
I took a look at how we're doing
insert document on the backend and you're right - we are using
.set. What would be your ideal UX here - the ability to toggle between
merge: true and
false? Or a separate query type for
Ultimately I would expect both a set option with
merge: true or
merge:false and a distinct
More important, in my opinion, is a distinct
insert action (especially since there is basic set functionality now). When letting Firestore set document id’s this isn’t so important, but when you are setting your own document id’s you don’t want to overwrite a document if you’re not expecting to. Preferably it would error…
Of course now, making the
insert action a true insert would be a breaking change to retool. Software is hard.
Thank you Justin.
This is good input @brettski!
I was just thinking naming the action
create may be an option for backwards compatibility. The fear here obviously is that many people have probably used insert and expect the current
set()-type functionality of it. So perhaps an option to add a
create action, and deprecate
Insert may be an option. Yeah, software is hard.
Im doing a collection update, and want to use the merge option too. Did this get added in to the retool interface?
For that matter are the array tools also available arrayUnion, arrayRemove ?