@furystack/mongodb-store 10.1.7 → 11.0.1
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/CHANGELOG.md +28 -0
- package/README.md +21 -8
- package/esm/define-mongodb-store.d.ts +37 -0
- package/esm/define-mongodb-store.d.ts.map +1 -0
- package/esm/define-mongodb-store.js +39 -0
- package/esm/define-mongodb-store.js.map +1 -0
- package/esm/define-mongodb-store.spec.d.ts +2 -0
- package/esm/define-mongodb-store.spec.d.ts.map +1 -0
- package/esm/define-mongodb-store.spec.js +93 -0
- package/esm/define-mongodb-store.spec.js.map +1 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -1
- package/esm/mongo-client-factory.d.ts +13 -15
- package/esm/mongo-client-factory.d.ts.map +1 -1
- package/esm/mongo-client-factory.js +25 -32
- package/esm/mongo-client-factory.js.map +1 -1
- package/esm/mongodb-store.d.ts +14 -3
- package/esm/mongodb-store.d.ts.map +1 -1
- package/esm/mongodb-store.js +15 -2
- package/esm/mongodb-store.js.map +1 -1
- package/esm/mongodb-store.spec.js +25 -49
- package/esm/mongodb-store.spec.js.map +1 -1
- package/package.json +7 -7
- package/src/define-mongodb-store.spec.ts +108 -0
- package/src/define-mongodb-store.ts +58 -0
- package/src/index.ts +2 -1
- package/src/mongo-client-factory.ts +35 -30
- package/src/mongodb-store.spec.ts +27 -53
- package/src/mongodb-store.ts +19 -5
- package/esm/store-manager-helpers.d.ts +0 -33
- package/esm/store-manager-helpers.d.ts.map +0 -1
- package/esm/store-manager-helpers.js +0 -15
- package/esm/store-manager-helpers.js.map +0 -1
- package/src/store-manager-helpers.ts +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [11.0.1] - 2026-05-21
|
|
4
|
+
|
|
5
|
+
### ♻️ Refactoring
|
|
6
|
+
|
|
7
|
+
### `update` throws `NotFoundError` for missing entities
|
|
8
|
+
|
|
9
|
+
`MongodbStore.update` now throws `NotFoundError` from `@furystack/core` (instead of a plain `Error`) when no document matches the given id. Callers can branch on `instanceof NotFoundError` without parsing messages. The message was tightened from `... cannot update!` to `... cannot update` — substring matches that look for `cannot update` keep working.
|
|
10
|
+
|
|
11
|
+
### ⬆️ Dependencies
|
|
12
|
+
|
|
13
|
+
- Bump `mongodb` to `7.2.0`.
|
|
14
|
+
- Bump dev `vitest` to `^4.1.5`.
|
|
15
|
+
- Bumped `@types/node` to `^25.9.1` and `vitest` to `^4.1.7`. No source changes — dev-tooling bump only.
|
|
16
|
+
|
|
17
|
+
### 📚 Documentation
|
|
18
|
+
|
|
19
|
+
- Rewrote JSDoc on `MongodbStore`, `defineMongodbStore`, and `MongoClientFactory` to follow the new value-test guidance: dropped restate-the-type narration, called out the lazy-init contract, the `_id`/`ObjectId` coercion behavior, and the fact that the store has no `[Symbol.asyncDispose]` because client lifetime belongs to the factory.
|
|
20
|
+
|
|
21
|
+
## [11.0.0] - 2026-04-25
|
|
22
|
+
|
|
23
|
+
### 💥 Breaking Changes
|
|
24
|
+
|
|
25
|
+
Stores are now first-class DI tokens. See the [v7 migration guide](../../docs/migrations/v7-functional-di.md) for rationale, recipes, and pitfalls.
|
|
26
|
+
|
|
27
|
+
- Removed `useMongoDb(...)`. Declare the store at module scope with `defineMongoDbStore<T, PK>({ name, model, primaryKey, url, db, collection, options? })`.
|
|
28
|
+
- `MongoClientFactory` is now an exported interface + `defineService({ lifetime: 'singleton' })` token. It pools `MongoClient` instances per URL and closes every pooled client on injector teardown.
|
|
29
|
+
- Dropped the unused `EventHub<{ onClientCreated, onDisposed }>` surface from the factory (no consumers in-repo).
|
|
30
|
+
|
|
3
31
|
## [10.1.7] - 2026-04-17
|
|
4
32
|
|
|
5
33
|
### ⬆️ Dependencies
|
package/README.md
CHANGED
|
@@ -12,19 +12,22 @@ yarn add @furystack/mongodb-store
|
|
|
12
12
|
|
|
13
13
|
## Initialization
|
|
14
14
|
|
|
15
|
+
`defineMongoDbStore` mints a `StoreToken` backed by a MongoDB collection.
|
|
16
|
+
The shared `MongoClientFactory` singleton pools `MongoClient` instances by
|
|
17
|
+
URL and closes them when the owning injector is disposed.
|
|
18
|
+
|
|
15
19
|
```ts
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
20
|
+
import { createInjector } from '@furystack/inject'
|
|
21
|
+
import { defineMongoDbStore } from '@furystack/mongodb-store'
|
|
22
|
+
import { defineDataSet } from '@furystack/repository'
|
|
19
23
|
|
|
20
24
|
export class TestEntry {
|
|
21
25
|
declare _id: string
|
|
22
26
|
declare value: string
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
injector: myInjector,
|
|
29
|
+
export const TestEntryStore = defineMongoDbStore<TestEntry, '_id'>({
|
|
30
|
+
name: 'my-app/TestEntryStore',
|
|
28
31
|
model: TestEntry,
|
|
29
32
|
primaryKey: '_id',
|
|
30
33
|
url: 'mongodb://localhost:27017',
|
|
@@ -32,7 +35,17 @@ useMongoDb({
|
|
|
32
35
|
collection: 'TestEntries',
|
|
33
36
|
})
|
|
34
37
|
|
|
35
|
-
const
|
|
38
|
+
export const TestEntryDataSet = defineDataSet({
|
|
39
|
+
name: 'my-app/TestEntryDataSet',
|
|
40
|
+
store: TestEntryStore,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const myInjector = createInjector()
|
|
44
|
+
const dataSet = myInjector.get(TestEntryDataSet)
|
|
36
45
|
```
|
|
37
46
|
|
|
38
|
-
> **Tip:** For application-level data access,
|
|
47
|
+
> **Tip:** For application-level data access, always go through a
|
|
48
|
+
> `DataSetToken` rather than resolving the `StoreToken` directly. The
|
|
49
|
+
> DataSet layer runs authorization, modification hooks, and entity-sync
|
|
50
|
+
> events; a direct store access skips all of them. The
|
|
51
|
+
> `furystack/no-direct-store-token` lint rule guards against this.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Constructable, StoreToken } from '@furystack/core';
|
|
2
|
+
import type { MongoClientOptions } from 'mongodb';
|
|
3
|
+
/**
|
|
4
|
+
* Options accepted by {@link defineMongoDbStore}.
|
|
5
|
+
*/
|
|
6
|
+
export type DefineMongoDbStoreOptions<T extends object, TPrimaryKey extends keyof T> = {
|
|
7
|
+
name: string;
|
|
8
|
+
model: Constructable<T>;
|
|
9
|
+
primaryKey: TPrimaryKey;
|
|
10
|
+
/** MongoDB deployment URL (e.g. `mongodb://localhost:27017`) — also acts as the pool key. */
|
|
11
|
+
url: string;
|
|
12
|
+
db: string;
|
|
13
|
+
collection: string;
|
|
14
|
+
options?: MongoClientOptions;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Mints a singleton {@link StoreToken} backed by a {@link MongodbStore}.
|
|
18
|
+
*
|
|
19
|
+
* Internally resolves the singleton {@link MongoClientFactory} so every store
|
|
20
|
+
* declared against the same `url` shares one {@link MongoClient}. Declare the
|
|
21
|
+
* token once at module scope — inline calls mint new identities and defeat
|
|
22
|
+
* singleton caching.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* export const UserStore = defineMongoDbStore({
|
|
27
|
+
* name: 'my-app/UserStore',
|
|
28
|
+
* model: User,
|
|
29
|
+
* primaryKey: 'username',
|
|
30
|
+
* url: 'mongodb://localhost:27017',
|
|
31
|
+
* db: 'my-app',
|
|
32
|
+
* collection: 'users',
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const defineMongoDbStore: <T extends object, const TPrimaryKey extends keyof T>(options: DefineMongoDbStoreOptions<T, TPrimaryKey>) => StoreToken<T, TPrimaryKey>;
|
|
37
|
+
//# sourceMappingURL=define-mongodb-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-mongodb-store.d.ts","sourceRoot":"","sources":["../src/define-mongodb-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAI9D;;GAEG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,SAAS,MAAM,CAAC,IAAI;IACrF,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;IACvB,UAAU,EAAE,WAAW,CAAA;IACvB,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,WAAW,SAAS,MAAM,CAAC,EACpF,SAAS,yBAAyB,CAAC,CAAC,EAAE,WAAW,CAAC,KACjD,UAAU,CAAC,CAAC,EAAE,WAAW,CAexB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineStore } from '@furystack/core';
|
|
2
|
+
import { MongoClientFactory } from './mongo-client-factory.js';
|
|
3
|
+
import { MongodbStore } from './mongodb-store.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mints a singleton {@link StoreToken} backed by a {@link MongodbStore}.
|
|
6
|
+
*
|
|
7
|
+
* Internally resolves the singleton {@link MongoClientFactory} so every store
|
|
8
|
+
* declared against the same `url` shares one {@link MongoClient}. Declare the
|
|
9
|
+
* token once at module scope — inline calls mint new identities and defeat
|
|
10
|
+
* singleton caching.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* export const UserStore = defineMongoDbStore({
|
|
15
|
+
* name: 'my-app/UserStore',
|
|
16
|
+
* model: User,
|
|
17
|
+
* primaryKey: 'username',
|
|
18
|
+
* url: 'mongodb://localhost:27017',
|
|
19
|
+
* db: 'my-app',
|
|
20
|
+
* collection: 'users',
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const defineMongoDbStore = (options) => defineStore({
|
|
25
|
+
name: options.name,
|
|
26
|
+
model: options.model,
|
|
27
|
+
primaryKey: options.primaryKey,
|
|
28
|
+
factory: ({ inject }) => {
|
|
29
|
+
const factory = inject(MongoClientFactory);
|
|
30
|
+
return new MongodbStore({
|
|
31
|
+
model: options.model,
|
|
32
|
+
primaryKey: options.primaryKey,
|
|
33
|
+
db: options.db,
|
|
34
|
+
collection: options.collection,
|
|
35
|
+
mongoClient: () => factory.getClientFor(options.url, options.options),
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=define-mongodb-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-mongodb-store.js","sourceRoot":"","sources":["../src/define-mongodb-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAgBjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAAkD,EACtB,EAAE,CAC9B,WAAW,CAAiB;IAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,UAAU,EAAE,OAAO,CAAC,UAAU;IAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACtB,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;QAC1C,OAAO,IAAI,YAAY,CAAiB;YACtC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC;SACtE,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-mongodb-store.spec.d.ts","sourceRoot":"","sources":["../src/define-mongodb-store.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createInjector } from '@furystack/inject';
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { defineMongoDbStore } from './define-mongodb-store.js';
|
|
4
|
+
import { MongoClientFactory } from './mongo-client-factory.js';
|
|
5
|
+
import { MongodbStore } from './mongodb-store.js';
|
|
6
|
+
class Item {
|
|
7
|
+
}
|
|
8
|
+
describe('defineMongoDbStore (metadata)', () => {
|
|
9
|
+
it('propagates name, lifetime, model and primaryKey onto the returned token', () => {
|
|
10
|
+
const token = defineMongoDbStore({
|
|
11
|
+
name: 'test/MongoItems',
|
|
12
|
+
model: Item,
|
|
13
|
+
primaryKey: 'id',
|
|
14
|
+
url: 'mongodb://localhost:27017',
|
|
15
|
+
db: 'unit-test',
|
|
16
|
+
collection: 'items',
|
|
17
|
+
});
|
|
18
|
+
expect(token.name).toBe('test/MongoItems');
|
|
19
|
+
expect(token.lifetime).toBe('singleton');
|
|
20
|
+
expect(token.model).toBe(Item);
|
|
21
|
+
expect(token.primaryKey).toBe('id');
|
|
22
|
+
});
|
|
23
|
+
it('mints a distinct token identity per call even when options match -- declare once at module scope', () => {
|
|
24
|
+
const options = {
|
|
25
|
+
name: 'test/MongoDupe',
|
|
26
|
+
model: Item,
|
|
27
|
+
primaryKey: 'id',
|
|
28
|
+
url: 'mongodb://localhost:27017',
|
|
29
|
+
db: 'unit-test',
|
|
30
|
+
collection: 'items',
|
|
31
|
+
};
|
|
32
|
+
const a = defineMongoDbStore(options);
|
|
33
|
+
const b = defineMongoDbStore(options);
|
|
34
|
+
expect(a.id).not.toBe(b.id);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('defineMongoDbStore (factory + disposal)', () => {
|
|
38
|
+
const buildClientStub = () => {
|
|
39
|
+
const createIndex = vi.fn(() => Promise.resolve('id_1'));
|
|
40
|
+
const collection = vi.fn(() => ({ createIndex }));
|
|
41
|
+
const db = vi.fn(() => ({ collection }));
|
|
42
|
+
const client = { db };
|
|
43
|
+
return { client, db, collection, createIndex };
|
|
44
|
+
};
|
|
45
|
+
it('instantiates a MongodbStore whose lazy client pulls from the injected MongoClientFactory with the right url', async () => {
|
|
46
|
+
const { client, db, collection, createIndex } = buildClientStub();
|
|
47
|
+
const getClientFor = vi.fn(() => client);
|
|
48
|
+
const Token = defineMongoDbStore({
|
|
49
|
+
name: 'test/MongoFactory',
|
|
50
|
+
model: Item,
|
|
51
|
+
primaryKey: 'id',
|
|
52
|
+
url: 'mongodb://stub-host:1234',
|
|
53
|
+
db: 'unit-db',
|
|
54
|
+
collection: 'unit-coll',
|
|
55
|
+
options: { appName: 'spec' },
|
|
56
|
+
});
|
|
57
|
+
const injector = createInjector();
|
|
58
|
+
injector.bind(MongoClientFactory, () => ({ getClientFor }));
|
|
59
|
+
try {
|
|
60
|
+
const store = injector.get(Token);
|
|
61
|
+
expect(store).toBeInstanceOf(MongodbStore);
|
|
62
|
+
expect(store.model).toBe(Item);
|
|
63
|
+
expect(store.primaryKey).toBe('id');
|
|
64
|
+
expect(getClientFor).not.toHaveBeenCalled();
|
|
65
|
+
await store.getCollection();
|
|
66
|
+
expect(getClientFor).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(getClientFor).toHaveBeenCalledWith('mongodb://stub-host:1234', { appName: 'spec' });
|
|
68
|
+
expect(db).toHaveBeenCalledWith('unit-db');
|
|
69
|
+
expect(collection).toHaveBeenCalledWith('unit-coll');
|
|
70
|
+
expect(createIndex).toHaveBeenCalledWith({ id: 1 }, { unique: true });
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
await injector[Symbol.asyncDispose]();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
it('disposing the injector tears down the bound MongoClientFactory', async () => {
|
|
77
|
+
const { client } = buildClientStub();
|
|
78
|
+
const getClientFor = vi.fn(() => client);
|
|
79
|
+
const Token = defineMongoDbStore({
|
|
80
|
+
name: 'test/MongoDispose',
|
|
81
|
+
model: Item,
|
|
82
|
+
primaryKey: 'id',
|
|
83
|
+
url: 'mongodb://stub-host:1234',
|
|
84
|
+
db: 'unit-db',
|
|
85
|
+
collection: 'unit-coll',
|
|
86
|
+
});
|
|
87
|
+
const injector = createInjector();
|
|
88
|
+
injector.bind(MongoClientFactory, () => ({ getClientFor }));
|
|
89
|
+
injector.get(Token);
|
|
90
|
+
await expect(injector[Symbol.asyncDispose]()).resolves.toBeUndefined();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=define-mongodb-store.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-mongodb-store.spec.js","sourceRoot":"","sources":["../src/define-mongodb-store.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,IAAI;CAGT;AAED,QAAQ,CAAC,+BA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,GAAG,cAAc,EAAE,CAAA;QACjC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAA;QAE3D,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACnB,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAA;IACxE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA"}
|
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Token } from '@furystack/inject';
|
|
2
2
|
import type { MongoClientOptions } from 'mongodb';
|
|
3
3
|
import { MongoClient } from 'mongodb';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Pools {@link MongoClient} instances by URL so every store that targets the
|
|
6
|
+
* same MongoDB deployment shares a single connection.
|
|
7
|
+
*
|
|
8
|
+
* Application code rarely calls this directly — {@link defineMongoDbStore}
|
|
9
|
+
* resolves the factory token internally. Exported for tests and advanced
|
|
10
|
+
* integrations that need raw client access (e.g. dropping a test database).
|
|
6
11
|
*/
|
|
7
|
-
export
|
|
8
|
-
onClientCreated: {
|
|
9
|
-
url: string;
|
|
10
|
-
};
|
|
11
|
-
onDisposed: undefined;
|
|
12
|
-
onListenerError: ListenerErrorPayload;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Factory for instantiating MongoDb clients
|
|
16
|
-
*/
|
|
17
|
-
export declare class MongoClientFactory extends EventHub<MongoClientFactoryEvents> implements AsyncDisposable {
|
|
18
|
-
private connections;
|
|
19
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
12
|
+
export interface MongoClientFactory {
|
|
20
13
|
getClientFor(url: string, options?: MongoClientOptions): MongoClient;
|
|
21
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Singleton token for the {@link MongoClientFactory}. Closes every pooled
|
|
17
|
+
* client when the owning injector is disposed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MongoClientFactory: Token<MongoClientFactory, 'singleton'>;
|
|
22
20
|
//# sourceMappingURL=mongo-client-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo-client-factory.d.ts","sourceRoot":"","sources":["../src/mongo-client-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongo-client-factory.d.ts","sourceRoot":"","sources":["../src/mongo-client-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIrC;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAAA;CACrE;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,WAAW,CAqBpE,CAAA"}
|
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Injectable } from '@furystack/inject';
|
|
8
|
-
import { EventHub } from '@furystack/utils';
|
|
1
|
+
import { defineService } from '@furystack/inject';
|
|
9
2
|
import { MongoClient } from 'mongodb';
|
|
10
3
|
/**
|
|
11
|
-
*
|
|
4
|
+
* Singleton token for the {@link MongoClientFactory}. Closes every pooled
|
|
5
|
+
* client when the owning injector is disposed.
|
|
12
6
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export { MongoClientFactory };
|
|
7
|
+
export const MongoClientFactory = defineService({
|
|
8
|
+
name: '@furystack/mongodb-store/MongoClientFactory',
|
|
9
|
+
lifetime: 'singleton',
|
|
10
|
+
factory: ({ onDispose }) => {
|
|
11
|
+
const connections = new Map();
|
|
12
|
+
onDispose(async () => {
|
|
13
|
+
await Promise.all([...connections.values()].map((c) => c.close(true)));
|
|
14
|
+
connections.clear();
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
getClientFor(url, options) {
|
|
18
|
+
const existing = connections.get(url);
|
|
19
|
+
if (existing) {
|
|
20
|
+
return existing;
|
|
21
|
+
}
|
|
22
|
+
const client = new MongoClient(url, options);
|
|
23
|
+
connections.set(url, client);
|
|
24
|
+
return client;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
36
29
|
//# sourceMappingURL=mongo-client-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo-client-factory.js","sourceRoot":"","sources":["../src/mongo-client-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongo-client-factory.js","sourceRoot":"","sources":["../src/mongo-client-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAgBrC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA2C,aAAa,CAAC;IACtF,IAAI,EAAE,6CAA6C;IACnD,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACzB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAA;QAClD,SAAS,CAAC,KAAK,IAAI,EAAE;YACnB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACtE,WAAW,CAAC,KAAK,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;QACF,OAAO;YACL,YAAY,CAAC,GAAW,EAAE,OAA4B;gBACpD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACrC,IAAI,QAAQ,EAAE,CAAC;oBACb,OAAO,QAAQ,CAAA;gBACjB,CAAC;gBACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;gBAC5C,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;gBAC5B,OAAO,MAAM,CAAA;YACf,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/esm/mongodb-store.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import type { CreateResult, FilterType, FindOptions, PartialResult, PhysicalStore, WithOptionalId } from '@furystack/core';
|
|
2
|
-
import type { Constructable } from '@furystack/inject';
|
|
1
|
+
import type { Constructable, CreateResult, FilterType, FindOptions, PartialResult, PhysicalStore, WithOptionalId } from '@furystack/core';
|
|
3
2
|
import { EventHub } from '@furystack/utils';
|
|
4
3
|
import type { Collection, MongoClient } from 'mongodb';
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* {@link PhysicalStore} backed by a MongoDB collection.
|
|
6
|
+
*
|
|
7
|
+
* The collection handle is resolved lazily on the first call via
|
|
8
|
+
* {@link getCollection}; if the primary key is not `_id` a unique index is
|
|
9
|
+
* created on it during init. Init failure clears the cached promise so the
|
|
10
|
+
* next call retries.
|
|
11
|
+
*
|
|
12
|
+
* When `primaryKey` is `_id`, string keys are transparently coerced to
|
|
13
|
+
* `ObjectId` for filters and back to hex strings on results so callers can
|
|
14
|
+
* stay in plain string-key territory.
|
|
15
|
+
*
|
|
16
|
+
* The store has no `[Symbol.asyncDispose]` — client lifetime belongs to
|
|
17
|
+
* {@link MongoClientFactory}, which closes pooled clients on injector teardown.
|
|
7
18
|
*/
|
|
8
19
|
export declare class MongodbStore<T extends object, TPrimaryKey extends keyof T, TWriteableData = WithOptionalId<T, TPrimaryKey>> extends EventHub<{
|
|
9
20
|
onEntityAdded: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-store.d.ts","sourceRoot":"","sources":["../src/mongodb-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"mongodb-store.d.ts","sourceRoot":"","sources":["../src/mongodb-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAU,WAAW,EAAkC,MAAM,SAAS,CAAA;AAS9F;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY,CACvB,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,MAAM,CAAC,EAC3B,cAAc,GAAG,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,CAE/C,SAAQ,QAAQ,CAAC;IACf,aAAa,EAAE;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;IAC5B,eAAe,EAAE;QAAE,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;KAAE,CAAA;IAC3D,eAAe,EAAE;QAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAA;KAAE,CAAA;CACzC,CACD,YAAW,aAAa,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC;IA+EtD,OAAO,CAAC,QAAQ,CAAC,OAAO;IA7E1B,SAAgB,UAAU,EAAE,WAAW,CAAA;IACvC,SAAgB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;IACvC,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,UAAU,CAAC,CAAe;IAElC,OAAO,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';
|
|
1
2
|
import { EventHub } from '@furystack/utils';
|
|
2
3
|
import { ObjectId } from 'mongodb';
|
|
3
4
|
// Improved type safety for hasObjectId
|
|
@@ -5,7 +6,19 @@ const hasObjectId = (value) => {
|
|
|
5
6
|
return value && typeof value === 'object' && value._id instanceof ObjectId;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* {@link PhysicalStore} backed by a MongoDB collection.
|
|
10
|
+
*
|
|
11
|
+
* The collection handle is resolved lazily on the first call via
|
|
12
|
+
* {@link getCollection}; if the primary key is not `_id` a unique index is
|
|
13
|
+
* created on it during init. Init failure clears the cached promise so the
|
|
14
|
+
* next call retries.
|
|
15
|
+
*
|
|
16
|
+
* When `primaryKey` is `_id`, string keys are transparently coerced to
|
|
17
|
+
* `ObjectId` for filters and back to hex strings on results so callers can
|
|
18
|
+
* stay in plain string-key territory.
|
|
19
|
+
*
|
|
20
|
+
* The store has no `[Symbol.asyncDispose]` — client lifetime belongs to
|
|
21
|
+
* {@link MongoClientFactory}, which closes pooled clients on injector teardown.
|
|
9
22
|
*/
|
|
10
23
|
export class MongodbStore extends EventHub {
|
|
11
24
|
options;
|
|
@@ -107,7 +120,7 @@ export class MongodbStore extends EventHub {
|
|
|
107
120
|
const collection = await this.getCollection();
|
|
108
121
|
const updateResult = await collection.updateOne(this.createIdFilter(id), { $set: data });
|
|
109
122
|
if (updateResult.matchedCount < 1) {
|
|
110
|
-
throw
|
|
123
|
+
throw new NotFoundError(`Entity not found with id '${String(id)}', cannot update`);
|
|
111
124
|
}
|
|
112
125
|
this.emit('onEntityUpdated', { id, change: data });
|
|
113
126
|
}
|
package/esm/mongodb-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-store.js","sourceRoot":"","sources":["../src/mongodb-store.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE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