Firebase Plugin update: Firestore collection group queries and increment

Sep 4 · 3 min read

We’ve released major update to React Studio’s (www.reactstudio.com) Firebase data plugin. You’ll get the update by opening your React Studio app and going into Plugins->Plugin manager and then click update next to Firebase plugin.

If you don’t have Firebase plugin installed then open the Plugin Store and install the plugin package there for free.

Whats new?

  • Cloud firestore Increment interaction
  • Cloud firestore Collection group queries
  • Set document name when creating a new document

Collection group queries

Collection group queries are really handy when you have collections inside documents. For example you could have Restaurant document and inside restaurant document you have “reviews” collection. It works well until you want to list reviews from more than one restaurant.

Cloud Firestore’s database now has a solution for querying between nested collections which is called Collection group query and React Studio is now supporting this feature. Just type prefix “group:” to Collection Id field in Data sheet and plugin will make collection group query instead of normal query.

Note that you need to update your Cloud Firestore’s database security rules to version 2.0 to be able to use Collection group queries: https://firebase.google.com/docs/rules/rules-behavior

Read more about Collection group queries from Firebase’s own blog:

Increment field value (e.g. creating a “Like” button)

Incrementing field value may be quite painful because you needed to use transactions for making sure transaction to keep data safe from concurrent writes. now you can use “increment” which will take care of queuing simultaneous increments when thousands of users are updating the same data.

You’ll find the increment in “Save data” -> Plugin interaction. In the screen shot below the increment interaction is used for creating Like and Unlike buttons for chat message.

Typical Like and Unlike buttons created with Increment interaction. You may test the example app here: https://neonto.cloud/u/chatdemoexamplemedium/

Set document name (create only)

In some cases it is wise to name the document instead of using Firestore’s automatic UUID as the document name. The reason could be e.g. that you want to create User document and use unique User Id as a name for the document. This way you can refer to document fast with just creating a path to document using Firebase Login’s user id. This also helps when making rules for user document. One can simply deny access if user’s id is not same as document name.

Set the document name in Save data interaction by using the “Document_Key” “column”. This sets the name when adding a new document to database. Please not that once you’ve created the document you cannot change the name anymore.

Setting the document name in Cloud Firestore database

Feel free to send us future development ideas for Firebase plugins to hello@neonto.com or post your ideas into our discussion forum at https://discuss.reactstudio.com/

React Studio

Written by

The premium app design tool for the most advanced JavaScript UI library — React JS www.neonto.com/reactstudio

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade