You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> All SQL flavours (PostgreSQL / MySQL / SQLite) are served by a single
@@ -139,6 +139,28 @@ The CLI infers the MongoDB driver from the `mongodb://` (or `mongodb+srv://`)
139
139
URL scheme automatically — no `OS_DATABASE_DRIVER` needed. Set
140
140
`OS_DATABASE_DRIVER=mongodb` only if you want to be explicit.
141
141
142
+
### Multi-tenancy: not supported
143
+
144
+
<Callouttype="warn">
145
+
The MongoDB driver is **single-tenant only**. It implements no row-level tenant
146
+
isolation — unlike `SqlDriver`, it ignores `DriverOptions.tenantId`, so reads
147
+
carry no tenant predicate and writes are not stamped with a tenant column.
148
+
</Callout>
149
+
150
+
Rather than serve a multi-tenant deployment without isolation, the driver
151
+
**refuses to start** in one ([#3724](https://github.com/objectstack-ai/objectstack/issues/3724)):
152
+
153
+
| Signal | Checked in | Result |
154
+
| :--- | :--- | :--- |
155
+
| Tenancy posture is not `single` — `OS_TENANCY_POSTURE=group`/`isolated`, or derived from `OS_MULTI_ORG_ENABLED=true`|`new MongoDBDriver()`, re-checked in `connect()`| throws `MongoDBMultiTenantUnsupportedError`; `objectstack serve` exits 1 |
156
+
| An object declares `tenancy.enabled: true`|`syncSchema()` / `syncSchemasBatch()`| throws, naming every offending object |
157
+
158
+
The error carries `code === 'MONGODB_MULTI_TENANT_UNSUPPORTED'`. There is no
159
+
override flag — one would restore exactly the silent cross-tenant access the
160
+
guard prevents. For multi-tenant deployments use `@objectstack/driver-sql`
161
+
(PostgreSQL / MySQL / SQLite), which enforces tenant scoping at the driver
162
+
level.
163
+
142
164
## SQLite (via `@objectstack/driver-sql`)
143
165
144
166
SQLite is ideal for local-first development and embedded applications.
Copy file name to clipboardExpand all lines: content/docs/deployment/self-hosting.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ workable default:
32
32
33
33
| Variable | Why it must be set |
34
34
|:---|:---|
35
-
|`OS_DATABASE_URL`| Without it, data lands in a SQLite file under the ObjectStack home directory (`~/.objectstack`, or `<cwd>/.objectstack` next to a project config) — fine for one box, wrong for containers. Use `postgres://…`, `mongodb://…`, or a mounted `file:…` path (`libsql://` / Turso is **not** supported by the open framework — that driver ships in ObjectStack Cloud). |
35
+
|`OS_DATABASE_URL`| Without it, data lands in a SQLite file under the ObjectStack home directory (`~/.objectstack`, or `<cwd>/.objectstack` next to a project config) — fine for one box, wrong for containers. Use `postgres://…`, `mongodb://…`, or a mounted `file:…` path (`libsql://` / Turso is **not** supported by the open framework — that driver ships in ObjectStack Cloud). `mongodb://…` is **single-tenant only**: the MongoDB driver has no row-level tenant isolation and refuses to boot unless the tenancy posture is `single` — see [Drivers → Multi-tenancy](/docs/data-modeling/drivers#multi-tenancy-not-supported). |
36
36
|`OS_AUTH_SECRET`| Session secret for the auth plugin (`AUTH_SECRET` is the legacy alias). Without it, `/api/v1/auth/*` is **silently skipped** — the server runs unauthenticated. |
37
37
|`OS_SECRET_KEY`| 32-byte master key encrypting every stored secret (`openssl rand -hex 32`). On a container's ephemeral filesystem the auto-minted key is **lost on restart**, making previously-encrypted secrets undecryptable. |
38
38
|`OS_PORT`|`os start`**fails loudly** if the port is busy (it never auto-shifts like `os dev`). Pin it and keep your reverse-proxy upstream in sync. |
-**Purpose**: Native MongoDB driver for ObjectQL with document-flavored objects
188
-
-**When to use**: Existing MongoDB infrastructure, document-shaped data
188
+
-**When to use**: Existing MongoDB infrastructure, document-shaped data — **single-tenant deployments only**
189
+
-**Not supported**: row-level tenant isolation. The driver refuses to boot when the tenancy posture is not `single` — see [Drivers → Multi-tenancy](/docs/data-modeling/drivers#multi-tenancy-not-supported)
| Tenancy posture is not `single` — `OS_TENANCY_POSTURE=group\|isolated`, or derived from `OS_MULTI_ORG_ENABLED=true`|`new MongoDBDriver()`, re-checked in `connect()` before a socket is opened | throws `MongoDBMultiTenantUnsupportedError`|
95
+
| An object declares `tenancy.enabled: true`|`syncSchema()` / `syncSchemasBatch()`| throws, naming every offending object |
96
+
97
+
The error carries `code === 'MONGODB_MULTI_TENANT_UNSUPPORTED'` so a host can
98
+
recognise it without matching on the message:
99
+
100
+
```typescript
101
+
import {
102
+
MongoDBMultiTenantUnsupportedError,
103
+
MULTI_TENANT_UNSUPPORTED_CODE,
104
+
} from'@objectstack/driver-mongodb';
105
+
```
106
+
107
+
There is deliberately **no override flag** — one would restore exactly the
108
+
silent cross-tenant access the guard exists to prevent. To run MongoDB, keep the
109
+
deployment single-tenant (`OS_TENANCY_POSTURE=single` or unset, `OS_MULTI_ORG_ENABLED`
110
+
unset or `false`, no object declaring `tenancy.enabled: true`); to go
111
+
multi-tenant, switch to `@objectstack/driver-sql`.
0 commit comments