@rebasepro/server-mongo 0.21.0 → 0.21.1-canary.g8c5a265
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -9,26 +9,26 @@ pnpm add @rebasepro/server-mongo
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
|
|
12
|
-
`import`.
|
|
13
|
-
`require(esm)
|
|
12
|
+
`import`. It needs Node `>=22.22.0` (its `engines` floor), where `require()`
|
|
13
|
+
of it resolves too: Node has supported `require(esm)` since 22.12.
|
|
14
14
|
|
|
15
15
|
## What This Package Does
|
|
16
16
|
|
|
17
|
-
Implements the Rebase `BackendBootstrapper` and backend interfaces for MongoDB. Provides a complete data driver, change-stream-based realtime,
|
|
17
|
+
Implements the Rebase `BackendBootstrapper` and backend interfaces for MongoDB. Provides a complete data driver, change-stream-based realtime, entity history, auth repositories, and WebSocket support. Plug it into `@rebasepro/server` via `createMongoBootstrapper()`, or use the standalone `createMongoBackend()` factory for direct access.
|
|
18
18
|
|
|
19
19
|
## Key Exports
|
|
20
20
|
|
|
21
21
|
| Export | Description |
|
|
22
22
|
|--------|-------------|
|
|
23
23
|
| `createMongoBootstrapper(config)` | Creates a `BackendBootstrapper` for use with `initializeRebaseBackend({ bootstrappers: [...] })`. |
|
|
24
|
-
| `createMongoBackend(config)` | Standalone factory — returns a `MongoBackendInstance` with driver,
|
|
24
|
+
| `createMongoBackend(config)` | Standalone factory — returns a `MongoBackendInstance` with driver, data service, realtime, admin, and lifecycle methods. |
|
|
25
25
|
| `createMongoDelegate(db)` | Convenience factory for just the `MongoDriver` (DataDriver). |
|
|
26
26
|
| `createMongoRealtimeService(db)` | Creates a MongoDB change-stream-based realtime provider. |
|
|
27
|
-
| `
|
|
27
|
+
| `createMongoEntityRepository(db)` | Creates a `DataRepository` for direct CRUD. |
|
|
28
28
|
| `createMongoDBConnection(url, dbName)` | Connects to MongoDB and returns a `MongoDBConnection` wrapper. |
|
|
29
29
|
| `MongoDBConnection` | `DatabaseConnection` implementation wrapping `MongoClient` + `Db`. |
|
|
30
30
|
| `MongoDriver` | The `DataDriver` implementation for MongoDB. |
|
|
31
|
-
| `
|
|
31
|
+
| `MongoDataService` | Low-level entity CRUD service (the `DataRepository` implementation). |
|
|
32
32
|
| `MongoRealtimeService` | Change-stream-based `RealtimeProvider`. |
|
|
33
33
|
| `MongoCollectionRegistry` | In-memory collection registry. |
|
|
34
34
|
| `isMongoBackendConfig(config)` | Type guard for `MongoBackendConfig`. |
|
|
@@ -74,11 +74,11 @@ const backend = createMongoBackend({
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// Use directly
|
|
77
|
-
const health = await backend.healthCheck();
|
|
78
|
-
const
|
|
77
|
+
const health = await backend.healthCheck?.();
|
|
78
|
+
const users = await backend.dataService.fetchCollection("users", {});
|
|
79
79
|
|
|
80
80
|
// Cleanup
|
|
81
|
-
await backend.destroy();
|
|
81
|
+
await backend.destroy?.();
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
## Related Packages
|
package/dist/index.es.js
CHANGED
|
@@ -1570,9 +1570,15 @@ var MongoDriver = class {
|
|
|
1570
1570
|
*/
|
|
1571
1571
|
async delete({ row, collection }) {
|
|
1572
1572
|
const { collection: resolvedCollection, callbacks, globalCallbacks, propertyCallbacks } = this.resolveCollectionCallbacks(collection, row.path);
|
|
1573
|
+
const stored = await this.fetchOne({
|
|
1574
|
+
path: row.path,
|
|
1575
|
+
id: row.id,
|
|
1576
|
+
collection: resolvedCollection
|
|
1577
|
+
});
|
|
1578
|
+
if (!stored) throw ApiError.notFound(`No row "${row.id}" in "${row.path}" to delete.`);
|
|
1573
1579
|
const callbackRow = {
|
|
1574
1580
|
id: row.id,
|
|
1575
|
-
...
|
|
1581
|
+
...stored
|
|
1576
1582
|
};
|
|
1577
1583
|
const contextForCallback = callContext(this, this.user, this.data, this.client);
|
|
1578
1584
|
try {
|
|
@@ -1638,7 +1644,7 @@ var MongoDriver = class {
|
|
|
1638
1644
|
action: "delete",
|
|
1639
1645
|
id: String(row.id),
|
|
1640
1646
|
tableName: row.path,
|
|
1641
|
-
previousValues:
|
|
1647
|
+
previousValues: stored,
|
|
1642
1648
|
updatedBy: this.user?.uid
|
|
1643
1649
|
}).catch((err) => {
|
|
1644
1650
|
logger.error(`Failed to record history for ${row.path}/${row.id}`, { error: err });
|
|
@@ -2963,7 +2969,7 @@ function createMongoBootstrapper(mongoConfig) {
|
|
|
2963
2969
|
},
|
|
2964
2970
|
mountRoutes() {},
|
|
2965
2971
|
async initializeWebsockets(server, realtimeService, driver, config, authAdapter) {
|
|
2966
|
-
const { createMongoWebSocket } = await import("./websocket-
|
|
2972
|
+
const { createMongoWebSocket } = await import("./websocket-Cc1T8ETt.js");
|
|
2967
2973
|
createMongoWebSocket(server, realtimeService, driver, config, cachedAdmin, authAdapter);
|
|
2968
2974
|
}
|
|
2969
2975
|
};
|