I'm setting up a multi-tenant database with RLS enabled. My users my have permissions set for multiple Teams, and as such when they query the database with the default $permissions set, they'll end up seeing data for multiple teams in one request.
When trying to query my TablesDB.listRows call to include a Query.contains for $permissions and my team ID (team:${getTeamId()}), I get "Attribute not found in schema: $permissions.
Is the assumption that $permissions isn't a queriable row attribute? Is there any way to handle multi-tenancy without having to update every single table to have a "tenant_id" column?
I can help with that. The issue is that $permissions isn’t a queryable attribute in the table schema it’s only used internally by the RLS engine to control access, so Query.contains() can’t filter on it. That’s why you’re getting the “Attribute not found in schema” error. For multi-tenancy, the usual approach is to store something like a team_id (tenant_id) column in the rows and apply queries or RLS rules based on that. Without a tenant column, the database can’t filter results per team during queries. Quick question: are you using a single database for all teams or separate collections/tables per team?
Gotcha. Currently I'm just using a single database for all teams, so all users and thus all teams interface with the same database and tables
Got it, that makes sense. When everything is in a single database like that, the cleanest way to handle multi-tenancy is usually by introducing a tenant/team identifier and using it with RLS policies so queries stay properly scoped. I’ve helped set up similar multi-tenant structures before, so I can walk you through the best approach and help implement it without breaking your current setup. If you want, feel free to DM me and we can go through your schema and permissions together.
Recommended threads
- Bulk API limitations in self-hosted serv...
Environment: Appwrite Selfhost SDK: node-appwrite 28.0 Calling `upsertRows` (also applies to `createRows`/`updateRows`/`deleteRows`) with more than 100 rows fa...
- Android SDK: Kotlin null Value Not Updat...
Hi team, I think you should check the Android SDK implementation once, as it seems to have an issue handling Kotlin **null** values. For example: When I send:...
- IMPORTANT! SOC-2 Request Failing
Issue requesting SOC-2. If tried other/private browser as well as filling in optional fields.