userbase icon indicating copy to clipboard operation
userbase copied to clipboard

Add unencrypted metadata to a database

Open Fubinator opened this issue 5 years ago • 2 comments
trafficstars

Sometimes it could be useful, similar to user profiles, to store unencrypted meta data in a database. An example would be a self implemented 1-n relation where the n databases have different user permissions.

A real world example would be: There are organizations and each organization has different users with different permissions. However, it is possible for users to be part of multiple organizations. If I now want to create teams within the organization, which include different users of the organization with different permissions, I have a problem.

Now, to get the teams of a user within an organization, I would either have to choose database names that contain the organization, or I would have to open ALL team databases of a user and open a team entry to filter out the right teams. Since database names are limited to 50 characters, it is not easy to ensure collision free names in the first approach. With the second approach I see serious performance issues in the long run.

One idea to solve this would be to store the organization ID as unencrypted meta data, so that you can easily filter for this meta data with getDatabases() without opening every database first.

Fubinator avatar Oct 22 '20 09:10 Fubinator

A couple follow-ups on this:

  1. In case it's useful here, we increased the database name limit to 100 characters in userbase-js v2.3.0

  2. Would it be acceptable in your use case to store a single separate database that contains the metadata tying organization names to database names? Seems there may be an admin organizing teams here, and the admin can share this single database among your users.

j-berman avatar Oct 28 '20 10:10 j-berman

Well, the limit of the database name already helps. We're already working around this by opening all databases on page load. Each team has it's own database entry (in it's own databse) anyway, so the teams have an id of the organization database, which works fine. So I'm no longer sure if this is a useful feature at all.

Fubinator avatar Oct 28 '20 10:10 Fubinator