Image for post
Image for post
Photo by Franck on Unsplash

I’ve just answered an interesting question on Stack Overflow that we can summarized as follows:

  • We have a Firestore collection named docs.
  • For each document of this collection, the read access right shall be granted to specific users group, depending on the document.
  • The users groups shall be defined in Firestore documents in a dedicateduserGroups collection.

As an example, let’s imagine we have two users groups, group1 and group2 and three documents doc1, doc2 and doc3. doc1 and doc3 can only be read by users of group2, and doc2 can only be read by users of group1.

So, how should…


Machine Learning

Adding Google Cloud Machine Learning capabilities to a web application

In this article, I will demonstrate how you can quickly develop a web application that “OCRises” an image and translates the resulting text by mixing and matching different Firebase and Google Cloud services: Cloud Functions, Firebase Extensions and Vision API.

Also, I will show how the core business logic of such an app can be implemented in no more that 25 lines of code!

The Travel Translator Demo App

Not only will I share those 25 lines of code 😃 , but I am going to share the full source code of the web app shown below!

Image for post
Image for post

As illustrated in the above screenshots, the Travel…


Image for post
Image for post
Photo by Joshua Golde on Unsplash

Quite often in a application you need to aggregate data and order the results of this aggregation.

For example, let’s imagine a Restaurant Reviews App where you want to display the Top 3 restaurants in terms of number of reviews.

In the SQL world, this is quite easy to accomplish. For example, for the following two tables:


TL;DR: In this article we share and explain the code for building a module which allows Firebase end-users with a specific Admin role creating other users and assigning them other specific user roles. This solution can be applied to Web, Android, iOS and Flutter apps built with Firebase.

Most applications need to implement a role-based access control system.

Role-based access control is a method of restricting (and granting) application access based on assigned user permissions, which differ according to the user’s role.

Firebase offers all the necessary “mechanisms” to implement such a system.

On one hand we have Firebase Authentication


With Cloud Firestore, we can combine multiple where() methods to create logical AND queries. These queries are called compound queries in the documentation.

However, as indicated in the documentation (Section “Query Limitations”):

Cloud Firestore does not support the following types of queries:
- …
- Logical OR queries. In this case, you should create a separate query for each OR condition and merge the query results in your app.
- …

The aim of this short article is to show how to implement, with the JavaScript SDK, the solution indicated above to “simulate” a Logical OR Query.

Firstly, let’s create a set of example data. Like the example in the documentation, we are going to create some Firestore records for a set of cities.

JavaScript code…


As detailed in the Cloud Firestore documentation, data in Firestore is stored into documents, which are “organized into collections”. Documents can contain subcollections which, in turn, can contains documents.

The documentation also indicates that:

Documents in subcollections can contain subcollections as well, allowing you to further nest data. You can nest data up to 100 levels deep.

Normally, as a Firestore database architect, while working out your data model, you decide the ids of the different subcollections of a document.

For example, for a Restaurants Reviews application, you may decide to have a reviews subcollection for each restaurant document¹.

And…

Renaud Tarnec

Google Developer Expert for Firebase // Full-Stack Web Application Dev & Project Manager // Vue.js, SPA and PWA aficionado // Freelance Consultant

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store