firebasefirebase-realtime-databasegoogle-cloud-functionsfirebase-adminfirebase-invites

What is the most reliable method for having isolated user-groups?


The question originally was:

How to create a new database instance upon user creation (per user)?

While I know that it isn't possible (yet), while I still think it is a good question - because, when looking at documentation alike Sharding and the Admin Database API, there is no way to create new Realtime Database instances through Cloud Functions, as one can do with the Firebase Console.

this is about, where I am stuck:

exports.admin_db_create = functions.database.ref('/db/{hookId}').onWrite(event => {
/* TODO: create a new database and assign the email address with the database. */
});

I've also found functions.database.instance, while this seems to return a reference to an existing database instance, but not creates one.

So let me rephrase the question:

What is the most reliable method for having isolated user-groups -

and how to harness Firebase Invites to invite into such a group?

I mean, so that a user could have his own "database" and invite his own team, without selling GSuite.


Solution

  • There is no API to automatically create Firebase Realtime Database instances.

    You'll either manually have to create a separate instance or project for each team, or separate them within a single database through security rules. If the separate teams are actually separate companies (based on your reference to GSuite), I'd highly recommend using separate Firebase projects for each of them,