nestjs-mongo 0.14.3 → 0.16.0

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +78 -31
  3. package/SECURITY.md +13 -0
  4. package/dist/constants.d.ts +1 -2
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +2 -3
  7. package/dist/constants.js.map +1 -1
  8. package/dist/entity/decorators.d.ts.map +1 -1
  9. package/dist/entity/decorators.js +1 -2
  10. package/dist/entity/decorators.js.map +1 -1
  11. package/dist/entity/entity.d.ts.map +1 -1
  12. package/dist/entity/entity.js +2 -2
  13. package/dist/entity/entity.js.map +1 -1
  14. package/dist/entity/filter.d.ts.map +1 -1
  15. package/dist/entity/filter.js +2 -2
  16. package/dist/entity/filter.js.map +1 -1
  17. package/dist/entity/interfaces.d.ts.map +1 -1
  18. package/dist/entity/manager.d.ts +3 -2
  19. package/dist/entity/manager.d.ts.map +1 -1
  20. package/dist/entity/manager.js +51 -36
  21. package/dist/entity/manager.js.map +1 -1
  22. package/dist/entity/paginated.d.ts.map +1 -1
  23. package/dist/entity/paginated.js +2 -2
  24. package/dist/entity/paginated.js.map +1 -1
  25. package/dist/entity/repository.d.ts +1 -1
  26. package/dist/entity/repository.d.ts.map +1 -1
  27. package/dist/entity/repository.js +14 -14
  28. package/dist/entity/repository.js.map +1 -1
  29. package/dist/entity/service.d.ts.map +1 -1
  30. package/dist/entity/service.js +9 -13
  31. package/dist/entity/service.js.map +1 -1
  32. package/dist/event/event.d.ts.map +1 -1
  33. package/dist/helpers.d.ts.map +1 -1
  34. package/dist/helpers.js +2 -2
  35. package/dist/helpers.js.map +1 -1
  36. package/dist/history/history.action.js +1 -1
  37. package/dist/history/history.action.js.map +1 -1
  38. package/dist/history/history.d.ts.map +1 -1
  39. package/dist/history/history.js +1 -1
  40. package/dist/history/history.js.map +1 -1
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +3 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/indexs/decorators.d.ts +2 -2
  46. package/dist/indexs/decorators.d.ts.map +1 -1
  47. package/dist/indexs/decorators.js +1 -2
  48. package/dist/indexs/decorators.js.map +1 -1
  49. package/dist/indexs/metadata.d.ts +2 -2
  50. package/dist/indexs/metadata.d.ts.map +1 -1
  51. package/dist/indexs/metadata.js +3 -4
  52. package/dist/indexs/metadata.js.map +1 -1
  53. package/dist/module/core.d.ts +4 -3
  54. package/dist/module/core.d.ts.map +1 -1
  55. package/dist/module/core.js +9 -7
  56. package/dist/module/core.js.map +1 -1
  57. package/dist/module/feature.d.ts +0 -3
  58. package/dist/module/feature.d.ts.map +1 -1
  59. package/dist/module/feature.js +3 -15
  60. package/dist/module/feature.js.map +1 -1
  61. package/dist/module/injection.d.ts +3 -4
  62. package/dist/module/injection.d.ts.map +1 -1
  63. package/dist/module/injection.js +7 -12
  64. package/dist/module/injection.js.map +1 -1
  65. package/dist/module/interfaces.d.ts +1 -5
  66. package/dist/module/interfaces.d.ts.map +1 -1
  67. package/dist/relationship/constraint.d.ts.map +1 -1
  68. package/dist/relationship/constraint.js +10 -7
  69. package/dist/relationship/constraint.js.map +1 -1
  70. package/dist/relationship/decorators.d.ts +2 -3
  71. package/dist/relationship/decorators.d.ts.map +1 -1
  72. package/dist/relationship/decorators.js +2 -3
  73. package/dist/relationship/decorators.js.map +1 -1
  74. package/dist/relationship/interfaces.d.ts +2 -2
  75. package/dist/relationship/interfaces.d.ts.map +1 -1
  76. package/dist/relationship/interfaces.js +1 -1
  77. package/dist/relationship/interfaces.js.map +1 -1
  78. package/dist/relationship/metadata.js +7 -8
  79. package/dist/relationship/metadata.js.map +1 -1
  80. package/dist/relationship/pipes/relationship.d.ts.map +1 -1
  81. package/dist/relationship/pipes/relationship.js +3 -3
  82. package/dist/relationship/pipes/relationship.js.map +1 -1
  83. package/dist/relationship/pipes/required.relationship.d.ts +1 -1
  84. package/dist/relationship/pipes/required.relationship.d.ts.map +1 -1
  85. package/dist/relationship/pipes/required.relationship.js +1 -1
  86. package/dist/relationship/pipes/required.relationship.js.map +1 -1
  87. package/dist/serializer/decorators.d.ts.map +1 -1
  88. package/dist/serializer/decorators.js +1 -2
  89. package/dist/serializer/decorators.js.map +1 -1
  90. package/dist/serializer/serializer.js +2 -3
  91. package/dist/serializer/serializer.js.map +1 -1
  92. package/dist/session/context.d.ts +9 -0
  93. package/dist/session/context.d.ts.map +1 -0
  94. package/dist/session/context.js +17 -0
  95. package/dist/session/context.js.map +1 -0
  96. package/dist/session/middleware.d.ts +1 -3
  97. package/dist/session/middleware.d.ts.map +1 -1
  98. package/dist/session/middleware.js +6 -8
  99. package/dist/session/middleware.js.map +1 -1
  100. package/dist/session/service.d.ts +1 -1
  101. package/dist/session/service.d.ts.map +1 -1
  102. package/dist/session/service.js +20 -17
  103. package/dist/session/service.js.map +1 -1
  104. package/dist/session/utils.d.ts.map +1 -1
  105. package/dist/transformer/objectId/index.d.ts +1 -1
  106. package/dist/transformer/objectId/index.d.ts.map +1 -1
  107. package/dist/transformer/objectId/index.js +2 -2
  108. package/dist/transformer/objectId/index.js.map +1 -1
  109. package/dist/transformer/objectId/objectid.pipe.d.ts.map +1 -1
  110. package/dist/transformer/objectId/objectid.pipe.js +3 -3
  111. package/dist/transformer/objectId/objectid.pipe.js.map +1 -1
  112. package/dist/transformer/slug.d.ts +3 -4
  113. package/dist/transformer/slug.d.ts.map +1 -1
  114. package/dist/transformer/slug.js +3 -5
  115. package/dist/transformer/slug.js.map +1 -1
  116. package/dist/transformer/utils.d.ts.map +1 -1
  117. package/dist/transformer/utils.js +2 -2
  118. package/dist/transformer/utils.js.map +1 -1
  119. package/dist/validation/unique/constraint.d.ts.map +1 -1
  120. package/dist/validation/unique/constraint.js +6 -3
  121. package/dist/validation/unique/constraint.js.map +1 -1
  122. package/dist/validation/unique/decorator.d.ts.map +1 -1
  123. package/dist/validation/unique/decorator.js +1 -2
  124. package/dist/validation/unique/decorator.js.map +1 -1
  125. package/package.json +57 -56
package/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.16.0] - 2026-11-15
8
+
9
+ ### BREAKING CHANGE
10
+
11
+ - Require the mongodb driver v7 (peer dependency `mongodb@^7`, MongoDB server 4.4 to 9.0)
12
+ - Node engine is now `>= 22.12.0` (required to load the ESM-only NestJS v12 packages with `require(esm)`)
13
+ - Drop NestJS v8 and v9, support NestJS v10, v11 and v12
14
+ - `find()` / `findOne()` options are typed `FindOptions` (no longer generic in the driver)
15
+ - Remove unused code: `getDataloaderToken()`, `MongoOptionsFactory` and the `WithValidRelationship` type (use `WithRelationshipTest`)
16
+ - `@Index()` and the `index.description` option of `@Relationship` are typed `Partial<IndexDescription>`: the `createIndexes` command options (`session`, `commitQuorum`...) are no longer accepted
17
+ - Replace cls-hooked (unmaintained) with Node's `AsyncLocalStorage` to store the mongo session of the current context. Use `runInSessionContext()` instead of a cls-hooked namespace; remove `SessionLoaderService.getSession()` and the `SESSION_LOADER_NAMESPACE` and `MONGO_SESSION_KEY` constants
18
+
19
+ ### Fixed
20
+
21
+ - Named connections: `MongoModule` and `MongoFeatureModule` no longer inject the default entity manager (an app with only named connections failed to start)
22
+ - `EntityManager.getRepository()` finds the repositories of named connections
23
+ - `@IsUnique` and `@IsValidRelationship` query the connection the model is registered on (they used the last created connection)
24
+ - `RequiredRelationshipPipe` throws a `NotFoundException` when the entity does not exist (it threw a `TypeError`)
25
+ - `EntityManager.isIdsQuery()` detects `{ _id: { $in: [...] } }` queries (it always returned `false`)
26
+
27
+ ### Changed
28
+
29
+ - Support class-validator v0.15 and reflect-metadata v0.2
30
+ - Use `instanceToPlain` / `plainToInstance` (the deprecated class-transformer aliases are no longer used)
31
+ - `SessionLoaderMiddleware` no longer depends on the express types
32
+ - `@Slugify` throws a plain `Error` (no import of a NestJS internal module)
33
+ - Remove the unused `uuid` and `global` dependencies
34
+ - Update dev dependencies (TypeScript 6, Jest 30, ESLint 10 with flat config, Prettier 3, typedoc 0.28) and switch to yarn v1
35
+ - CI: tests on Node 24 and 26 with MongoDB 6.0, 7.0 and 8.0, and a smoke test on Node 22; bump all GitHub Actions
36
+ - Release workflow: create the GitHub release with the `gh` CLI and stage the npm release (trusted publishing with provenance), see `RELEASING.md`
37
+ - Define package contents with the `files` field in `package.json` (replaces `.npmignore`)
38
+
39
+ ### Added
40
+
41
+ - Documentation: TSDoc on the public API, a new README, guides in the [wiki](https://github.com/Pop-Code/nestjs-mongo/wiki)
42
+ - `getModelEntityManager()` helper
43
+ - `runInSessionContext()`, `hasSessionContext()` and `SessionLoaderService.run()`
44
+ - `startSessionWithTransaction(fn, { useContext: true })` runs in its own session context: it no longer needs `SessionLoaderMiddleware`, and does not change the session of an outer context
45
+ - Tests for named connections, transactions, session contexts (including an express end-to-end test) and pipes
46
+
47
+ ## [0.15.0] - 2025-06-30
48
+
49
+ ### Changed
50
+
51
+ - Support NestJS v11
52
+ - Support the mongodb driver v6
package/README.md CHANGED
@@ -1,52 +1,99 @@
1
1
  # nestjs-mongo
2
2
 
3
- [NestJS Mongo][doc-link] is a module that provide a little orm. Build with typescript and the nodejs mongodb driver
3
+ [![Test](https://github.com/Pop-Code/nestjs-mongo/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Pop-Code/nestjs-mongo/actions/workflows/test.yml)
4
+ [![npm](https://img.shields.io/npm/v/nestjs-mongo.svg)][npm]
5
+ [![codecov](https://codecov.io/gh/Pop-Code/nestjs-mongo/branch/master/graph/badge.svg)](https://codecov.io/gh/Pop-Code/nestjs-mongo)
4
6
 
5
- ### [Install FROM NPM][npm]
7
+ A small ORM-like module for [NestJS](https://nestjs.com), built with TypeScript on top of the official [mongodb driver](https://www.mongodb.com/docs/drivers/node/current/).
8
+
9
+ - Models as classes, transformed with class-transformer and validated with class-validator on save
10
+ - An entity manager per connection, and an injectable repository per model
11
+ - Relationships with validation, loading helpers and cascade delete
12
+ - `@Index` and `@IsUnique` decorators
13
+ - Transactions shared by all the operations of a request
14
+ - Change streams, route parameter pipes, serialization helpers
15
+
16
+ It does not hide the driver: queries are plain mongodb filters, and cursors are native cursors.
17
+
18
+ ## Requirements
19
+
20
+ | nestjs-mongo | NestJS | mongodb driver | MongoDB server | Node.js |
21
+ | ------------ | ---------- | -------------- | -------------- | -------- |
22
+ | 0.16.x | 10, 11, 12 | 7.x | 4.4 to 9.0 | >= 22.12 |
23
+ | 0.15.x | 11 | 6.x | 4.0 to 8.0 | >= 20 |
24
+ | 0.14.x | 8, 9 | 4.x | 3.6 to 6.0 | >= 14 |
25
+
26
+ Transactions and change streams require a replica set.
27
+
28
+ ## Install
6
29
 
7
30
  ```bash
8
- npm install nestjs-mongo
9
- # or unig yarn
10
- yarn add nestjs-mongo
31
+ npm install nestjs-mongo mongodb class-validator
32
+ # or
33
+ yarn add nestjs-mongo mongodb class-validator
11
34
  ```
12
35
 
13
- ### Usage
14
-
15
- An example of nestjs module that import the nestjs-mongo
36
+ ## Quick start
16
37
 
17
38
  ```ts
18
- // module.ts
19
- import { Module } from '@nestjs/common';
20
- import { MongoModule } from 'nestjs-mongo';
21
-
39
+ // app.module.ts
22
40
  @Module({
23
41
  imports: [
24
42
  MongoModule.forRootAsync({
25
- imports: [],
26
- useFactory: (config: ConfigService) => ({
27
- uri: config.mongoUri
28
- }),
29
- inject: [MyConfigService]
30
- })
31
- ]
43
+ useFactory: () => ({
44
+ uri: 'mongodb://localhost:27017/my-app',
45
+ exceptionFactory: (errors) => new BadRequestException(errors)
46
+ })
47
+ }),
48
+ MongoModule.forFeature({ models: [User] })
49
+ ],
50
+ providers: [UserService]
32
51
  })
33
- export class MyModule {}
34
- ```
52
+ export class AppModule {}
53
+
54
+ // user.entity.ts
55
+ @Collection('users')
56
+ export class User extends Entity {
57
+ @IsEmail()
58
+ @IsUnique()
59
+ email: string;
60
+
61
+ @IsString()
62
+ name: string;
63
+ }
64
+
65
+ // user.service.ts
66
+ @Injectable()
67
+ export class UserService {
68
+ constructor(@InjectEntityRepository(User) private readonly users: EntityRepository<User>) {}
35
69
 
36
- ....More coming soon.
70
+ async register(email: string, name: string) {
71
+ return await this.users.save(this.users.fromPlain({ email, name })); // validated, then inserted
72
+ }
37
73
 
38
- ### Documentation
74
+ async findByEmail(email: string) {
75
+ return await this.users.findOne({ email }); // a User instance, or undefined
76
+ }
77
+ }
78
+ ```
79
+
80
+ ## Documentation
39
81
 
40
- A typedoc is generated and available on github [https://pop-code.github.io/nestjs-mongo][doc-link]
82
+ - [Wiki](https://github.com/Pop-Code/nestjs-mongo/wiki)
83
+ - [API](https://pop-code.github.io/nestjs-mongo)
84
+ - [Changelog](https://github.com/Pop-Code/nestjs-mongo/blob/master/CHANGELOG.md)
41
85
 
42
- ### [CHANGELOG][changelog]
86
+ ## Development
43
87
 
44
- #### TODO
88
+ ```bash
89
+ yarn install
90
+ docker run -d --name mongo -p 27017:27017 mongo:8.0 --replSet test-rs
91
+ docker exec mongo mongosh --quiet --eval 'rs.initiate({_id:"test-rs",members:[{_id:0,host:"localhost:27017"}]})'
92
+ yarn lint && yarn build && yarn test
93
+ yarn doc # regenerate the API reference in ./docs
94
+ ```
45
95
 
46
- - [ ] write wiki
47
- - [ ] add more tests
48
- - [ ] add examples
96
+ The tests use `mongodb://localhost:27017` (see `test/constants.ts`) and need Node.js >= 24.9 (Jest loads the ESM-only NestJS 12 packages).
97
+ See [RELEASING.md](./RELEASING.md) to publish a version.
49
98
 
50
99
  [npm]: https://www.npmjs.com/package/nestjs-mongo
51
- [doc-link]: https://pop-code.github.io/nestjs-mongo
52
- [changelog]: https://github.com/Pop-Code/nestjs-mongo/blob/master/CHANGELOG.md
package/SECURITY.md ADDED
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 0.16.x | :white_check_mark: |
8
+ | < 0.16 | :x: |
9
+
10
+ ## Reporting a Vulnerability
11
+
12
+ If you found one or more vulnerabilities, please create an issue.
13
+ If the review is accepted, we will publish a fix patch.
@@ -3,7 +3,6 @@ export declare const DEFAULT_CONNECTION_NAME = "nestjs-mongo:connection:default"
3
3
  export declare const NAMED_CONNECTION_TOKEN = "nestjs-mongo:connection:name";
4
4
  export declare const RELATIONSHIP_METADATA_NAME = "nestjs-mongo:relationship";
5
5
  export declare const RELATIONSHIP_LIST_METADATA_NAME = "nestjs-mongo:relationship_list";
6
+ export declare const MODEL_ENTITY_MANAGER_METADATA_NAME = "nestjs-mongo:entity_manager";
6
7
  export declare const INDEX_METADATA_NAME = "nestjs-mongo:index";
7
- export declare const SESSION_LOADER_NAMESPACE = "nestjs-mongo:ns_sessionloader";
8
- export declare const MONGO_SESSION_KEY = "ns_sessionloader:mongo_client_session";
9
8
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,iBAAiB,CAAC;AACpC,eAAO,MAAM,uBAAuB,oCAAoC,CAAC;AACzE,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AACrE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,+BAA+B,mCAAmC,CAAC;AAChF,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,iBAAiB,0CAA0C,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,iBAAiB,CAAC;AACpC,eAAO,MAAM,uBAAuB,oCAAoC,CAAC;AACzE,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AACrE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,+BAA+B,mCAAmC,CAAC;AAChF,eAAO,MAAM,kCAAkC,gCAAgC,CAAC;AAChF,eAAO,MAAM,mBAAmB,uBAAuB,CAAC"}
package/dist/constants.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MONGO_SESSION_KEY = exports.SESSION_LOADER_NAMESPACE = exports.INDEX_METADATA_NAME = exports.RELATIONSHIP_LIST_METADATA_NAME = exports.RELATIONSHIP_METADATA_NAME = exports.NAMED_CONNECTION_TOKEN = exports.DEFAULT_CONNECTION_NAME = exports.DEBUG = void 0;
3
+ exports.INDEX_METADATA_NAME = exports.MODEL_ENTITY_MANAGER_METADATA_NAME = exports.RELATIONSHIP_LIST_METADATA_NAME = exports.RELATIONSHIP_METADATA_NAME = exports.NAMED_CONNECTION_TOKEN = exports.DEFAULT_CONNECTION_NAME = exports.DEBUG = void 0;
4
4
  exports.DEBUG = 'nestjs-mongo';
5
5
  exports.DEFAULT_CONNECTION_NAME = 'nestjs-mongo:connection:default';
6
6
  exports.NAMED_CONNECTION_TOKEN = 'nestjs-mongo:connection:name';
7
7
  exports.RELATIONSHIP_METADATA_NAME = 'nestjs-mongo:relationship';
8
8
  exports.RELATIONSHIP_LIST_METADATA_NAME = 'nestjs-mongo:relationship_list';
9
+ exports.MODEL_ENTITY_MANAGER_METADATA_NAME = 'nestjs-mongo:entity_manager';
9
10
  exports.INDEX_METADATA_NAME = 'nestjs-mongo:index';
10
- exports.SESSION_LOADER_NAMESPACE = 'nestjs-mongo:ns_sessionloader';
11
- exports.MONGO_SESSION_KEY = 'ns_sessionloader:mongo_client_session';
12
11
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG,cAAc,CAAC;AACvB,QAAA,uBAAuB,GAAG,iCAAiC,CAAC;AAC5D,QAAA,sBAAsB,GAAG,8BAA8B,CAAC;AACxD,QAAA,0BAA0B,GAAG,2BAA2B,CAAC;AACzD,QAAA,+BAA+B,GAAG,gCAAgC,CAAC;AACnE,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,+BAA+B,CAAC;AAC3D,QAAA,iBAAiB,GAAG,uCAAuC,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG,cAAc,CAAC;AACvB,QAAA,uBAAuB,GAAG,iCAAiC,CAAC;AAC5D,QAAA,sBAAsB,GAAG,8BAA8B,CAAC;AACxD,QAAA,0BAA0B,GAAG,2BAA2B,CAAC;AACzD,QAAA,+BAA+B,GAAG,gCAAgC,CAAC;AACnE,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AACnE,QAAA,mBAAmB,GAAG,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/entity/decorators.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,YACnB,GAAG,UACtB"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/entity/decorators.ts"],"names":[],"mappings":"AASA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,IAC3B,QAAQ,GAAG,UACtB"}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Collection = void 0;
3
+ exports.Collection = Collection;
4
4
  function Collection(name) {
5
5
  return (target) => Reflect.defineMetadata('mongo:collectionName', name, target);
6
6
  }
7
- exports.Collection = Collection;
8
7
  //# sourceMappingURL=decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/entity/decorators.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,IAAY;IACnC,OAAO,CAAC,MAAW,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACzF,CAAC;AAFD,gCAEC"}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/entity/decorators.ts"],"names":[],"mappings":";;AASA,gCAEC;AAFD,SAAgB,UAAU,CAAC,IAAY;IACnC,OAAO,CAAC,MAAW,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACzF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/entity/entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAgB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,MAAO,SAAQ,qBAAqB;CAAG;AAExD,8BACsB,MAAO,YAAW,eAAe;IAEnD,GAAG,EAAE,QAAQ,CAAC;IAId,SAAS,EAAE,IAAI,CAAc;IAK7B,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB"}
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/entity/entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAgB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,MAAO,SAAQ,qBAAqB;CAAG;AAOxD,8BACsB,MAAO,YAAW,eAAe;IAEnD,GAAG,EAAE,QAAQ,CAAC;IAId,SAAS,EAAE,IAAI,CAAc;IAK7B,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB"}
@@ -20,6 +20,7 @@ let Entity = class Entity {
20
20
  this.createdAt = new Date();
21
21
  }
22
22
  };
23
+ exports.Entity = Entity;
23
24
  __decorate([
24
25
  (0, objectId_1.TypeObjectId)(),
25
26
  __metadata("design:type", mongodb_1.ObjectId)
@@ -35,8 +36,7 @@ __decorate([
35
36
  (0, class_validator_1.IsOptional)(),
36
37
  __metadata("design:type", Date)
37
38
  ], Entity.prototype, "updatedAt", void 0);
38
- Entity = __decorate([
39
+ exports.Entity = Entity = __decorate([
39
40
  (0, serializer_1.Serializable)()
40
41
  ], Entity);
41
- exports.Entity = Entity;
42
42
  //# sourceMappingURL=entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity/entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAqD;AACrD,qCAAmC;AAEnC,8CAAoE;AACpE,sDAAuD;AAMhD,IAAe,MAAM,GAArB,MAAe,MAAM;IAArB;QAMH,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;IAMjC,CAAC;CAAA,CAAA;AAXG;IAAC,IAAA,uBAAY,GAAE;8BACV,kBAAQ;mCAAC;AAEd;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,IAAA,wBAAM,GAAE;8BACE,IAAI;yCAAc;AAE7B;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,IAAA,wBAAM,GAAE;IACR,IAAA,4BAAU,GAAE;8BACD,IAAI;yCAAC;AAXC,MAAM;IAD3B,IAAA,yBAAY,GAAE;GACO,MAAM,CAY3B;AAZqB,wBAAM"}
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity/entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAqD;AACrD,qCAAmC;AAEnC,8CAAoE;AACpE,sDAAuD;AAWhD,IAAe,MAAM,GAArB,MAAe,MAAM;IAArB;QAMH,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;IAMjC,CAAC;CAAA,CAAA;AAZqB,wBAAM;AAExB;IADC,IAAA,uBAAY,GAAE;8BACV,kBAAQ;mCAAC;AAId;IAFC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,IAAA,wBAAM,GAAE;8BACE,IAAI;yCAAc;AAK7B;IAHC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,IAAA,wBAAM,GAAE;IACR,IAAA,4BAAU,GAAE;8BACD,IAAI;yCAAC;iBAXC,MAAM;IAD3B,IAAA,yBAAY,GAAE;GACO,MAAM,CAY3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/entity/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,WAAW,MAAO,SAAQ,qBAAqB;CAAG;AAExD,qBACa,MAAM;IAIf,IAAI,SAAK;IAOT,KAAK,SAAM;IAMX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAe;IAEjC,OAAO,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAalC,qBAAqB,IAAI;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;KAAE;IAevD,OAAO;CAIV"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/entity/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,WAAW,MAAO,SAAQ,qBAAqB;CAAG;AAQxD,qBACa,MAAM;IAIf,IAAI,SAAK;IAOT,KAAK,SAAM;IAMX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAe;IAKjC,OAAO,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAgBlC,qBAAqB,IAAI;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;KAAE;IAkBvD,OAAO;CAIV"}
@@ -49,6 +49,7 @@ let Filter = class Filter {
49
49
  return query;
50
50
  }
51
51
  };
52
+ exports.Filter = Filter;
52
53
  __decorate([
53
54
  (0, class_validator_1.IsInt)(),
54
55
  (0, class_validator_1.IsOptional)(),
@@ -70,8 +71,7 @@ __decorate([
70
71
  (0, class_validator_1.Matches)(/^(.+):(asc|desc)$/, { each: true }),
71
72
  __metadata("design:type", Array)
72
73
  ], Filter.prototype, "orderBy", void 0);
73
- Filter = __decorate([
74
+ exports.Filter = Filter = __decorate([
74
75
  (0, serializer_1.Serializable)()
75
76
  ], Filter);
76
- exports.Filter = Filter;
77
77
  //# sourceMappingURL=filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/entity/filter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAoD;AACpD,qDAAuF;AAEvF,8CAAoE;AAK7D,IAAM,MAAM,GAAZ,MAAM,MAAM;IAAZ;QAIH,SAAI,GAAG,CAAC,CAAC;QAOT,UAAK,GAAG,EAAE,CAAC;QAMX,YAAO,GAAc,CAAC,SAAS,CAAC,CAAC;IAkCrC,CAAC;IAhCG,OAAO;QACH,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;YAC5B,OAAO,EAAE,CAAC;SACb;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAY,EAAE,WAAW,EAAE,EAAE;YACrD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,C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,IAAI,EAAE,IAAI,EAAE,CAAC;;uCACZ;iBAjBxB,MAAM;IADlB,IAAA,yBAAY,GAAE;GACF,MAAM,CA4DlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/entity/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC1D,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/entity/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAKtD,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC1D,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B"}
@@ -22,7 +22,7 @@ export declare class EntityManager {
22
22
  getClient(): MongoClient;
23
23
  getDatabase(databaseName?: string): import("mongodb").Db;
24
24
  getSessionLoaderService(): SessionLoaderService;
25
- getSessionContext(): import("../session/types").ClientSessionContext;
25
+ getSessionContext(): import("..").ClientSessionContext;
26
26
  setSessionContext(mongoSession: ClientSession): void;
27
27
  clearSessionContext(): void;
28
28
  getCollectionName<Model extends EntityInterface>(nameOrInstance: Model | ClassConstructor<Model>): string;
@@ -32,7 +32,7 @@ export declare class EntityManager {
32
32
  skipValidation?: boolean;
33
33
  validatorOptions?: ValidatorOptions;
34
34
  }): Promise<WithId<Model>>;
35
- find<Model extends EntityInterface>(classType: ClassConstructor<Model>, query: Filter<Model>, options?: FindOptions<Model>): Promise<FindCursor<WithId<Model>>>;
35
+ find<Model extends EntityInterface>(classType: ClassConstructor<Model>, query: Filter<Model>, options?: FindOptions): Promise<FindCursor<WithId<Model>>>;
36
36
  findOne<Model extends EntityInterface>(classType: ClassConstructor<Model>, query: Filter<Model>, options?: FindOptions): Promise<WithId<Model> | undefined>;
37
37
  count<Model extends EntityInterface>(classType: ClassConstructor<Model>, query: Filter<Model>, options?: CountDocumentsOptions): Promise<number>;
38
38
  isIdQuery(query: any): boolean;
@@ -52,4 +52,5 @@ export declare class EntityManager {
52
52
  merge<Model extends EntityInterface>(entity: Model, data: Model, excludePrefixes?: string[]): Model;
53
53
  createIndexs<Model extends EntityInterface>(model: ClassConstructor<Model>): Promise<string[] | undefined>;
54
54
  }
55
+ export declare function getModelEntityManager(model: any): EntityManager | undefined;
55
56
  //# sourceMappingURL=manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/entity/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAqB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EAEX,gBAAgB,EAChB,WAAW,EAEX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACT,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC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C,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IA+CtB,2BAA2B,CAC7B,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,CAAC,EACvD,OAAO,GAAE;QACL,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;QACxC,cAAc,CAAC,EAAE,oBAAoB,CAAC;KACpC,GACP,OAAO,CAAC,aAAa,CAAC;IAwBzB,SAAS,CAAC,KAAK,SAAS,eAAe,EACnC,SAAS,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,GAChC,KAAK;IAQR,KAAK,CAAC,KAAK,SAAS,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE;IASrF,YAAY,CAAC,KAAK,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;CA6BnF;AAOD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,GAAG,SAAS,CAG3E"}
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.EntityManager = void 0;
28
+ exports.getModelEntityManager = getModelEntityManager;
28
29
  const common_1 = require("@nestjs/common");
29
30
  const class_validator_1 = require("class-validator");
30
31
  const debug_1 = __importDefault(require("debug"));
@@ -36,6 +37,7 @@ const indexs_1 = require("../indexs");
36
37
  const injection_1 = require("../module/injection");
37
38
  const interfaces_1 = require("../relationship/interfaces");
38
39
  const metadata_1 = require("../relationship/metadata");
40
+ const context_1 = require("../session/context");
39
41
  const service_1 = require("../session/service");
40
42
  const utils_1 = require("../transformer/utils");
41
43
  let EntityManager = class EntityManager {
@@ -51,6 +53,7 @@ let EntityManager = class EntityManager {
51
53
  return __awaiter(this, void 0, void 0, function* () {
52
54
  this.log('Add model %s as %s', model.name, name);
53
55
  this.models.set(name, model);
56
+ Reflect.defineMetadata(constants_1.MODEL_ENTITY_MANAGER_METADATA_NAME, this, model);
54
57
  const collectionName = this.getCollectionName(model);
55
58
  const cursor = this.getDatabase().listCollections({ name: collectionName });
56
59
  if ((yield cursor.toArray()).length === 0) {
@@ -74,6 +77,11 @@ let EntityManager = class EntityManager {
74
77
  return this;
75
78
  }
76
79
  getRepository(classType) {
80
+ for (const repository of this.repositories.values()) {
81
+ if (repository.getClassType() === classType) {
82
+ return repository;
83
+ }
84
+ }
77
85
  return this.repositories.get((0, injection_1.getEntityRepositoryToken)(classType.name));
78
86
  }
79
87
  getClient() {
@@ -107,8 +115,8 @@ let EntityManager = class EntityManager {
107
115
  getCollection(nameOrInstance, databaseName) {
108
116
  return this.getDatabase(databaseName).collection(this.getCollectionName(nameOrInstance));
109
117
  }
110
- validate(obj, validatorOptions = {}, throwError = false) {
111
- return __awaiter(this, void 0, void 0, function* () {
118
+ validate(obj_1) {
119
+ return __awaiter(this, arguments, void 0, function* (obj, validatorOptions = {}, throwError = false) {
112
120
  const errors = yield (0, class_validator_1.validate)(obj, Object.assign({ validationError: { target: true, value: true }, whitelist: true }, validatorOptions));
113
121
  if (errors.length > 0 && throwError) {
114
122
  throw this.exceptionFactory(errors);
@@ -116,9 +124,9 @@ let EntityManager = class EntityManager {
116
124
  return errors;
117
125
  });
118
126
  }
119
- save(entity, options = {}) {
120
- var _a;
121
- return __awaiter(this, void 0, void 0, function* () {
127
+ save(entity_1) {
128
+ return __awaiter(this, arguments, void 0, function* (entity, options = {}) {
129
+ var _a;
122
130
  const entityName = entity.constructor.name;
123
131
  const ctx = this.getSessionContext();
124
132
  try {
@@ -167,16 +175,16 @@ let EntityManager = class EntityManager {
167
175
  }
168
176
  });
169
177
  }
170
- find(classType, query, options = {}) {
171
- return __awaiter(this, void 0, void 0, function* () {
178
+ find(classType_1, query_1) {
179
+ return __awaiter(this, arguments, void 0, function* (classType, query, options = {}) {
172
180
  this.log('find %s %o', classType.name, query);
173
181
  const ctx = this.getSessionContext();
174
182
  const cursor = this.getCollection(classType).find(query, Object.assign(Object.assign({}, (ctx !== undefined ? { session: ctx.session } : {})), options));
175
183
  return cursor.map((data) => this.fromPlain(classType, data));
176
184
  });
177
185
  }
178
- findOne(classType, query, options = {}) {
179
- return __awaiter(this, void 0, void 0, function* () {
186
+ findOne(classType_1, query_1) {
187
+ return __awaiter(this, arguments, void 0, function* (classType, query, options = {}) {
180
188
  this.log('findOne %s %o', classType.name, query, options);
181
189
  const ctx = this.getSessionContext();
182
190
  const obj = yield this.getCollection(classType).findOne(query, Object.assign(Object.assign({}, (ctx !== undefined ? { session: ctx.session } : {})), options));
@@ -185,8 +193,8 @@ let EntityManager = class EntityManager {
185
193
  }
186
194
  });
187
195
  }
188
- count(classType, query, options = {}) {
189
- return __awaiter(this, void 0, void 0, function* () {
196
+ count(classType_1, query_1) {
197
+ return __awaiter(this, arguments, void 0, function* (classType, query, options = {}) {
190
198
  this.log('count %s %o', classType.name, query);
191
199
  const ctx = this.getSessionContext();
192
200
  const collection = this.getCollection(classType);
@@ -197,7 +205,8 @@ let EntityManager = class EntityManager {
197
205
  return Object.keys(query).length === 1 && query._id instanceof mongodb_1.ObjectId;
198
206
  }
199
207
  isIdsQuery(query) {
200
- return this.isIdQuery(query) && Array.isArray(query._id.$in);
208
+ var _a;
209
+ return Object.keys(query).length === 1 && Array.isArray((_a = query._id) === null || _a === void 0 ? void 0 : _a.$in);
201
210
  }
202
211
  deleteCascade(classType, entity) {
203
212
  return __awaiter(this, void 0, void 0, function* () {
@@ -222,8 +231,8 @@ let EntityManager = class EntityManager {
222
231
  }
223
232
  });
224
233
  }
225
- deleteOne(classType, query, options = {}) {
226
- return __awaiter(this, void 0, void 0, function* () {
234
+ deleteOne(classType_1, query_1) {
235
+ return __awaiter(this, arguments, void 0, function* (classType, query, options = {}) {
227
236
  this.log('deleteOne %s %o', classType.name, query);
228
237
  const ctx = this.getSessionContext();
229
238
  const entity = yield this.findOne(classType, query);
@@ -235,8 +244,8 @@ let EntityManager = class EntityManager {
235
244
  return result;
236
245
  });
237
246
  }
238
- deleteMany(classType, query, options = {}) {
239
- return __awaiter(this, void 0, void 0, function* () {
247
+ deleteMany(classType_1, query_1) {
248
+ return __awaiter(this, arguments, void 0, function* (classType, query, options = {}) {
240
249
  this.log('deleteMany %s %o', classType.name, query);
241
250
  const ctx = this.getSessionContext();
242
251
  const items = yield this.find(classType, query, options);
@@ -253,8 +262,8 @@ let EntityManager = class EntityManager {
253
262
  const ctx = this.getSessionContext();
254
263
  return this.getCollection(classType).watch(pipes, Object.assign(Object.assign({}, (ctx !== undefined ? { session: ctx.session } : {})), options));
255
264
  }
256
- getRelationship(obj, property, options = {}) {
257
- return __awaiter(this, void 0, void 0, function* () {
265
+ getRelationship(obj_1, property_1) {
266
+ return __awaiter(this, arguments, void 0, function* (obj, property, options = {}) {
258
267
  this.log('getRelationship %s on %s', property, obj);
259
268
  const relationMetadata = (0, metadata_1.getRelationshipMetadata)(obj.constructor, property, this, obj);
260
269
  if ((0, class_validator_1.isEmpty)(relationMetadata)) {
@@ -267,14 +276,13 @@ let EntityManager = class EntityManager {
267
276
  if (!(id instanceof mongodb_1.ObjectId)) {
268
277
  return;
269
278
  }
270
- const filter = {};
271
- filter._id = id;
279
+ const filter = { _id: id };
272
280
  const relationship = yield this.findOne(relationMetadata.type, filter, options);
273
281
  return relationship;
274
282
  });
275
283
  }
276
- getRelationships(obj, property, options = {}) {
277
- return __awaiter(this, void 0, void 0, function* () {
284
+ getRelationships(obj_1, property_1) {
285
+ return __awaiter(this, arguments, void 0, function* (obj, property, options = {}) {
278
286
  this.log('getRelationships %s on %s', property, obj);
279
287
  const relationMetadata = (0, metadata_1.getRelationshipMetadata)(obj.constructor, property, this);
280
288
  if ((0, class_validator_1.isEmpty)(relationMetadata) || relationMetadata === undefined) {
@@ -293,19 +301,22 @@ let EntityManager = class EntityManager {
293
301
  return yield relationshipsCursor.toArray();
294
302
  });
295
303
  }
296
- startSessionWithTransaction(transactionFn, options = {}) {
297
- var _a, _b;
298
- return __awaiter(this, void 0, void 0, function* () {
304
+ startSessionWithTransaction(transactionFn_1) {
305
+ return __awaiter(this, arguments, void 0, function* (transactionFn, options = {}) {
306
+ var _a;
299
307
  const session = this.getClient().startSession((_a = options.sessionOptions) !== null && _a !== void 0 ? _a : {});
300
- const useContext = options.useContext === true;
301
- useContext && this.setSessionContext(session);
302
- try {
303
- yield session.withTransaction(() => __awaiter(this, void 0, void 0, function* () { return yield transactionFn(session); }), (_b = options.transactionOptions) !== null && _b !== void 0 ? _b : {});
304
- }
305
- finally {
306
- useContext && this.clearSessionContext();
307
- yield session.endSession();
308
- }
308
+ const run = () => __awaiter(this, void 0, void 0, function* () {
309
+ var _a;
310
+ if (options.useContext === true)
311
+ this.setSessionContext(session);
312
+ try {
313
+ yield session.withTransaction(() => __awaiter(this, void 0, void 0, function* () { return yield transactionFn(session); }), (_a = options.transactionOptions) !== null && _a !== void 0 ? _a : {});
314
+ }
315
+ finally {
316
+ yield session.endSession();
317
+ }
318
+ });
319
+ yield (options.useContext === true ? (0, context_1.runInSessionContext)(run) : run());
309
320
  return session;
310
321
  });
311
322
  }
@@ -347,10 +358,14 @@ let EntityManager = class EntityManager {
347
358
  });
348
359
  }
349
360
  };
350
- EntityManager = __decorate([
361
+ exports.EntityManager = EntityManager;
362
+ exports.EntityManager = EntityManager = __decorate([
351
363
  __param(0, (0, injection_1.InjectMongoClient)()),
352
364
  __metadata("design:paramtypes", [mongodb_1.MongoClient,
353
365
  service_1.SessionLoaderService, Function])
354
366
  ], EntityManager);
355
- exports.EntityManager = EntityManager;
367
+ function getModelEntityManager(model) {
368
+ const target = typeof model === 'function' ? model : model === null || model === void 0 ? void 0 : model.constructor;
369
+ return target !== undefined ? Reflect.getMetadata(constants_1.MODEL_ENTITY_MANAGER_METADATA_NAME, target) : undefined;
370
+ }
356
371
  //# sourceMappingURL=manager.js.map