Lack of firestore features

Hello guys,

I've been using Retool lately to create an admin panel and I think there are some important features missing in firestore integration.

There are no:

  • firebase.firestore.FieldValue.arrayUnion
  • firebase.firestore.FieldValue.arrayRemove

I know I can just fetch the latest item and add the items to it, but there is a huge concurrency problem: what if, while I am changing it another user changes it? What is the final version?

A user already asked about that feature in Sep '20 (How do I add or remove a value in an array in a firestore document?)
That was your reply:

Hey @cdedreuille! We don’t have native support for this quite yet, so your best bet is to pass a fully updated array in your query. So basically take the current value of the array, push new values to it via JS, and then pass that updated array to overwrite the existing one. Does that make sense? (We’re working on building a raw query editor so you’ll be able to access the SDK directly!)

Now, after one year, still nothing.

  • Missing * not-in

  • Realtime Updates

One of the greatest features of Firestore is the real-time updates and if it could be used in Retool that would be great.

3 Likes

Hey @gzaccaroni! I'm sorry that you've run into issues here :confused:

We do support most basic (and some advanced) operations for querying Firestore, so I'm not sure it's fair to say that it's not "real" – but we certainly could do a better job of supporting more specific array operations. We've just been focused on more of the core experience lately (see our weekly changelog) and Firebase has taken a bit of a back seat. It's definitely something we're hoping to improve in the future!

If you'd like access to the beta for the raw query editor, just shoot me an email (justin at retool) and we can get you set up.

1 Like

You’re right, the problem is that it is frustrating to not be able to do something. I’ve updated the topic title.

Thank you for the invitation!

@gzaccaroni Thanks for the post, exactly the features we also need. Together with:

What we're also missing are document updates over the dot notation (Official Firebase Docs). This is quite dangerous right now on retool when you experience the missing support for the first time. The operation will just not fail and create an additional property on the document and mess up the data structure.

Using these features are best-practices of working with Firestore. Right now it can be solved by creating an http endpoint, implemented the operations there and call it over retool.
Because retool is all about helping us provide secure admin backends quickly it'd be awesome when you support these operations as well!

@justin When the beta program is still open and we can use the dot annotation updates with it, I'd love to have access as well.

Thanks anyways for creating retool! :hugs:

1 Like

I will second the vote for supporting serverTimeStamp. It's very useful for some applications, and as long as you don't need to query on this field, it's there for free.

FieldValue.delete() is not working. Always returns 422.

How is the correct way to remove a field from a firebase doc using RAW query?

await db.firestore().collection('testCollection').doc('02vc6Jgf2AxFwh82eELa').update(
{
      domain: db.firestore().FieldValue.delete()

});

Hey @Flavio_Bosco!

Can you try the following?

await db
  .firestore()
  .collection("testCollection")
  .doc("your_doc_id")
  .update({ your_field_key: firestore.FieldValue.delete() });

You should also be able to reference firestore.FieldValue.serverTimestamp() in raw queries as well @gcardwel!

I am pretty sure that firestore.FieldValue.serverTimestamp() only works in the context of update or set operations, not queries.

The docs here:

say that create_time and update_time are returned with the document object from the server. There are complaints that these aren't like other fields in that they can't be searched / indexed, which is true. If you want to search / index on this data, you have to add that data to the document fields. But in my case, I just want the data itself as part of the document metadata, and presently these are not available from a query in retool.

:thinking: are you able firestore.FieldValue.serverTimestamp() in queries outside of Retool? Based on this thread it looks like, while you can query for fields that were generated by it you can't use it in the query itself, instead you'd need something like firestore.Timestamp.now()

FWIW moment() and new Date() also seem to work in that field.

Also, out of curiosity, are you just looking to query against the values generated by serverTimestamp or is there a particular reason you want to use serverTimestamp itself in the filter?