@rapidrest/service-core 1.0.0-beta.6 → 1.0.0-rc.2
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/dist/lib/database/MongoRepository.js +22 -24
- package/dist/lib/database/MongoRepository.js.map +1 -1
- package/dist/lib/database/MongoSchemaSync.js +80 -21
- package/dist/lib/database/MongoSchemaSync.js.map +1 -1
- package/dist/lib/database/NamingUtils.js +4 -4
- package/dist/lib/database/NamingUtils.js.map +1 -1
- package/dist/lib/decorators/PersistenceDecorators.js +17 -17
- package/dist/lib/decorators/PersistenceDecorators.js.map +1 -1
- package/dist/lib/models/BaseMongoEntity.js +10 -3
- package/dist/lib/models/BaseMongoEntity.js.map +1 -1
- package/dist/lib/models/ModelUtils.js +31 -34
- package/dist/lib/models/ModelUtils.js.map +1 -1
- package/dist/lib/models/RecoverableBaseMongoEntity.js +11 -3
- package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -1
- package/dist/lib/models/RepoUtils.js +37 -45
- package/dist/lib/models/RepoUtils.js.map +1 -1
- package/dist/lib/models/SimpleEntity.js +1 -1
- package/dist/lib/models/SimpleEntity.js.map +1 -1
- package/dist/lib/routes/ModelRoute.js +1 -11
- package/dist/lib/routes/ModelRoute.js.map +1 -1
- package/dist/types/database/MongoRepository.d.ts +17 -11
- package/dist/types/database/MongoSchemaSync.d.ts +25 -3
- package/dist/types/database/NamingUtils.d.ts +1 -1
- package/dist/types/decorators/PersistenceDecorators.d.ts +29 -3
- package/dist/types/models/ModelUtils.d.ts +3 -6
- package/dist/types/models/RepoUtils.d.ts +1 -7
- package/dist/types/routes/ModelRoute.d.ts +0 -4
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +7 -7
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +1 -1
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +2 -2
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +5 -5
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +2 -2
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +7 -7
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +2 -2
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +2 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +5 -6
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +3 -3
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +3 -3
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/CollationOptions.md +79 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +4 -4
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +5 -5
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/EntityOptions.md +32 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +4 -4
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +15 -5
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +1 -1
- package/docs/reference/classes/ACLUtils.md +10 -10
- package/docs/reference/classes/AdminRoute.md +3 -3
- package/docs/reference/classes/AuthMiddleware.md +6 -6
- package/docs/reference/classes/BackgroundService.md +8 -8
- package/docs/reference/classes/BackgroundServiceManager.md +7 -7
- package/docs/reference/classes/BaseEntity.md +6 -6
- package/docs/reference/classes/BaseMongoEntity.md +7 -7
- package/docs/reference/classes/BasicStrategy.md +5 -5
- package/docs/reference/classes/BasicStrategyOptions.md +7 -7
- package/docs/reference/classes/BulkError.md +3 -3
- package/docs/reference/classes/ConnectionManager.md +4 -4
- package/docs/reference/classes/EventListenerManager.md +5 -5
- package/docs/reference/classes/HttpRouter.md +16 -16
- package/docs/reference/classes/JWTStrategy.md +5 -5
- package/docs/reference/classes/JWTStrategyOptions.md +8 -8
- package/docs/reference/classes/MetricsRoute.md +2 -2
- package/docs/reference/classes/ModelRoute.md +46 -46
- package/docs/reference/classes/ModelUtils.md +13 -31
- package/docs/reference/classes/MongoConnection.md +12 -12
- package/docs/reference/classes/MongoRepository.md +73 -37
- package/docs/reference/classes/MongoSchemaSync.md +37 -7
- package/docs/reference/classes/NetUtils.md +3 -3
- package/docs/reference/classes/NotificationUtils.md +3 -3
- package/docs/reference/classes/ObjectFactory.md +3 -3
- package/docs/reference/classes/OpenAPIRoute.md +5 -5
- package/docs/reference/classes/OpenApiSpec.md +45 -45
- package/docs/reference/classes/RecoverableBaseEntity.md +7 -7
- package/docs/reference/classes/RecoverableBaseMongoEntity.md +8 -8
- package/docs/reference/classes/RedisTransport.md +4 -4
- package/docs/reference/classes/RepoUtils.md +36 -40
- package/docs/reference/classes/RouteUtils.md +7 -7
- package/docs/reference/classes/Server.md +26 -26
- package/docs/reference/classes/SimpleEntity.md +3 -3
- package/docs/reference/classes/SimpleMongoEntity.md +4 -4
- package/docs/reference/classes/StatusExtraData.md +4 -4
- package/docs/reference/classes/StatusRoute.md +1 -1
- package/docs/reference/classes/UWSRequest.md +16 -16
- package/docs/reference/classes/UWSResponse.md +13 -13
- package/docs/reference/classes/UWSWebSocketShim.md +5 -5
- package/docs/reference/enumerations/ACLAction.md +7 -7
- package/docs/reference/enumerations/ApiErrorMessages.md +15 -15
- package/docs/reference/enumerations/ApiErrors.md +15 -15
- package/docs/reference/functions/createWebSocketStream.md +1 -1
- package/docs/reference/functions/isSqlDataSource.md +1 -1
- package/docs/reference/functions/readBody.md +1 -1
- package/docs/reference/functions/resolveCollectionName.md +2 -2
- package/docs/reference/functions/runChain.md +1 -1
- package/docs/reference/functions/snakeCase.md +1 -1
- package/docs/reference/interfaces/ACLRecord.md +8 -8
- package/docs/reference/interfaces/AccessControlList.md +5 -5
- package/docs/reference/interfaces/AuthResult.md +5 -5
- package/docs/reference/interfaces/AuthStrategy.md +4 -4
- package/docs/reference/interfaces/CreateRequestOptions.md +9 -9
- package/docs/reference/interfaces/DeleteRequestOptions.md +10 -20
- package/docs/reference/interfaces/FindRequestOptions.md +10 -10
- package/docs/reference/interfaces/HttpRequest.md +15 -15
- package/docs/reference/interfaces/HttpResponse.md +11 -11
- package/docs/reference/interfaces/JWTAuthResult.md +6 -6
- package/docs/reference/interfaces/RepoCreateOptions.md +7 -7
- package/docs/reference/interfaces/RepoDeleteOptions.md +8 -18
- package/docs/reference/interfaces/RepoFindOptions.md +10 -20
- package/docs/reference/interfaces/RepoOperationOptions.md +6 -6
- package/docs/reference/interfaces/RepoUpdateOptions.md +7 -17
- package/docs/reference/interfaces/RequestOptions.md +8 -8
- package/docs/reference/interfaces/RequestWS.md +17 -17
- package/docs/reference/interfaces/TruncateRequestOptions.md +12 -26
- package/docs/reference/interfaces/UpdateRequestOptions.md +10 -20
- package/docs/reference/type-aliases/ErrorHandler.md +1 -1
- package/docs/reference/type-aliases/NextFunction.md +1 -1
- package/docs/reference/type-aliases/OneOrMany.md +1 -1
- package/docs/reference/type-aliases/OneOrNull.md +1 -1
- package/docs/reference/type-aliases/PartialBaseEntity.md +1 -1
- package/docs/reference/type-aliases/PartialSimpleEntity.md +1 -1
- package/docs/reference/type-aliases/RequestHandler.md +1 -1
- package/docs/reference/type-aliases/UpdateObject.md +1 -1
- package/docs/reference/type-aliases/WsUpgradeAuth.md +1 -1
- package/docs/reference/type-aliases/WsUpgradeAuthResult.md +5 -5
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MongoRepository\<T\>
|
|
8
8
|
|
|
9
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
9
|
+
Defined in: [src/database/MongoRepository.ts:28](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L28)
|
|
10
10
|
|
|
11
11
|
Provides a lightweight repository for performing common operations against a single MongoDB collection using the
|
|
12
12
|
native `mongodb` driver. Instances of this class are obtained via `MongoConnection.getRepository`.
|
|
@@ -30,7 +30,7 @@ Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
|
30
30
|
|
|
31
31
|
> **new MongoRepository**\<`T`\>(`db`, `collection`, `modelClass?`): `MongoRepository`\<`T`\>
|
|
32
32
|
|
|
33
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
33
|
+
Defined in: [src/database/MongoRepository.ts:36](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L36)
|
|
34
34
|
|
|
35
35
|
#### Parameters
|
|
36
36
|
|
|
@@ -56,7 +56,7 @@ Defined in: [src/database/MongoRepository.ts:30](https://github.com/rapidrest/se
|
|
|
56
56
|
|
|
57
57
|
> `readonly` **collection**: `Collection`\<`T`\>
|
|
58
58
|
|
|
59
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
59
|
+
Defined in: [src/database/MongoRepository.ts:32](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L32)
|
|
60
60
|
|
|
61
61
|
The underlying MongoDB collection that operations are performed against.
|
|
62
62
|
|
|
@@ -66,7 +66,7 @@ The underlying MongoDB collection that operations are performed against.
|
|
|
66
66
|
|
|
67
67
|
> `readonly` **db**: `Db`
|
|
68
68
|
|
|
69
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
69
|
+
Defined in: [src/database/MongoRepository.ts:30](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L30)
|
|
70
70
|
|
|
71
71
|
The database that the underlying collection belongs to.
|
|
72
72
|
|
|
@@ -76,7 +76,7 @@ The database that the underlying collection belongs to.
|
|
|
76
76
|
|
|
77
77
|
> `readonly` **modelClass**: `any`
|
|
78
78
|
|
|
79
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
79
|
+
Defined in: [src/database/MongoRepository.ts:34](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L34)
|
|
80
80
|
|
|
81
81
|
The model class associated with this repository.
|
|
82
82
|
|
|
@@ -88,7 +88,7 @@ The model class associated with this repository.
|
|
|
88
88
|
|
|
89
89
|
> **get** **collectionName**(): `string`
|
|
90
90
|
|
|
91
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
91
|
+
Defined in: [src/database/MongoRepository.ts:43](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L43)
|
|
92
92
|
|
|
93
93
|
The name of the underlying MongoDB collection.
|
|
94
94
|
|
|
@@ -102,7 +102,7 @@ The name of the underlying MongoDB collection.
|
|
|
102
102
|
|
|
103
103
|
> **aggregate**(`pipeline`): `AggregationCursor`\<`any`\>
|
|
104
104
|
|
|
105
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
105
|
+
Defined in: [src/database/MongoRepository.ts:52](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L52)
|
|
106
106
|
|
|
107
107
|
Executes the given aggregation pipeline against the collection and returns the resulting cursor.
|
|
108
108
|
|
|
@@ -124,7 +124,7 @@ The aggregation pipeline stages to execute.
|
|
|
124
124
|
|
|
125
125
|
> **clear**(): `Promise`\<`void`\>
|
|
126
126
|
|
|
127
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
127
|
+
Defined in: [src/database/MongoRepository.ts:60](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L60)
|
|
128
128
|
|
|
129
129
|
Drops the entire collection from the database, removing all documents and indexes. Does nothing if the
|
|
130
130
|
collection does not exist.
|
|
@@ -137,9 +137,9 @@ collection does not exist.
|
|
|
137
137
|
|
|
138
138
|
### count()
|
|
139
139
|
|
|
140
|
-
> **count**(`filter?`): `Promise`\<`number`\>
|
|
140
|
+
> **count**(`filter?`, `options?`): `Promise`\<`number`\>
|
|
141
141
|
|
|
142
|
-
Defined in: [src/database/MongoRepository.ts:70](https://github.com/rapidrest/service-core/blob/
|
|
142
|
+
Defined in: [src/database/MongoRepository.ts:70](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L70)
|
|
143
143
|
|
|
144
144
|
Returns the number of documents matching the given filter.
|
|
145
145
|
|
|
@@ -147,9 +147,15 @@ Returns the number of documents matching the given filter.
|
|
|
147
147
|
|
|
148
148
|
##### filter?
|
|
149
149
|
|
|
150
|
-
`
|
|
150
|
+
`Filter`\<`T`\>
|
|
151
151
|
|
|
152
|
-
The
|
|
152
|
+
The filter for the count
|
|
153
|
+
|
|
154
|
+
##### options?
|
|
155
|
+
|
|
156
|
+
`CountDocumentsOptions`
|
|
157
|
+
|
|
158
|
+
Optional settings for the command
|
|
153
159
|
|
|
154
160
|
#### Returns
|
|
155
161
|
|
|
@@ -159,9 +165,9 @@ The query filter to match documents against.
|
|
|
159
165
|
|
|
160
166
|
### deleteMany()
|
|
161
167
|
|
|
162
|
-
> **deleteMany**(`filter`): `Promise`\<`DeleteResult`\>
|
|
168
|
+
> **deleteMany**(`filter`, `options?`): `Promise`\<`DeleteResult`\>
|
|
163
169
|
|
|
164
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
170
|
+
Defined in: [src/database/MongoRepository.ts:80](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L80)
|
|
165
171
|
|
|
166
172
|
Deletes all documents matching the given filter.
|
|
167
173
|
|
|
@@ -169,10 +175,16 @@ Deletes all documents matching the given filter.
|
|
|
169
175
|
|
|
170
176
|
##### filter
|
|
171
177
|
|
|
172
|
-
`
|
|
178
|
+
`Filter`\<`T`\>
|
|
173
179
|
|
|
174
180
|
The query filter to match documents against.
|
|
175
181
|
|
|
182
|
+
##### options?
|
|
183
|
+
|
|
184
|
+
`DeleteOptions`
|
|
185
|
+
|
|
186
|
+
Optional settings for the command
|
|
187
|
+
|
|
176
188
|
#### Returns
|
|
177
189
|
|
|
178
190
|
`Promise`\<`DeleteResult`\>
|
|
@@ -181,20 +193,26 @@ The query filter to match documents against.
|
|
|
181
193
|
|
|
182
194
|
### deleteOne()
|
|
183
195
|
|
|
184
|
-
> **deleteOne**(`filter`): `Promise`\<`DeleteResult`\>
|
|
196
|
+
> **deleteOne**(`filter?`, `options?`): `Promise`\<`DeleteResult`\>
|
|
185
197
|
|
|
186
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
198
|
+
Defined in: [src/database/MongoRepository.ts:90](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L90)
|
|
187
199
|
|
|
188
200
|
Deletes the first document matching the given filter.
|
|
189
201
|
|
|
190
202
|
#### Parameters
|
|
191
203
|
|
|
192
|
-
##### filter
|
|
204
|
+
##### filter?
|
|
193
205
|
|
|
194
|
-
`
|
|
206
|
+
`Filter`\<`T`\>
|
|
195
207
|
|
|
196
208
|
The query filter to match documents against.
|
|
197
209
|
|
|
210
|
+
##### options?
|
|
211
|
+
|
|
212
|
+
`DeleteOptions`
|
|
213
|
+
|
|
214
|
+
Optional settings for the command
|
|
215
|
+
|
|
198
216
|
#### Returns
|
|
199
217
|
|
|
200
218
|
`Promise`\<`DeleteResult`\>
|
|
@@ -205,7 +223,7 @@ The query filter to match documents against.
|
|
|
205
223
|
|
|
206
224
|
> **distinct**(`field`, `filter?`): `Promise`\<`any`[]\>
|
|
207
225
|
|
|
208
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
226
|
+
Defined in: [src/database/MongoRepository.ts:100](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L100)
|
|
209
227
|
|
|
210
228
|
Returns the list of distinct values of the given field for all documents matching the given filter.
|
|
211
229
|
|
|
@@ -219,7 +237,7 @@ The name of the document field to return distinct values of.
|
|
|
219
237
|
|
|
220
238
|
##### filter?
|
|
221
239
|
|
|
222
|
-
`
|
|
240
|
+
`Filter`\<`T`\>
|
|
223
241
|
|
|
224
242
|
The query filter to match documents against.
|
|
225
243
|
|
|
@@ -231,9 +249,9 @@ The query filter to match documents against.
|
|
|
231
249
|
|
|
232
250
|
### find()
|
|
233
251
|
|
|
234
|
-
> **find**(`filter?`): `
|
|
252
|
+
> **find**(`filter?`, `options?`): `FindCursor`\<`T`\>
|
|
235
253
|
|
|
236
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
254
|
+
Defined in: [src/database/MongoRepository.ts:110](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L110)
|
|
237
255
|
|
|
238
256
|
Returns all documents matching the given filter.
|
|
239
257
|
|
|
@@ -241,21 +259,27 @@ Returns all documents matching the given filter.
|
|
|
241
259
|
|
|
242
260
|
##### filter?
|
|
243
261
|
|
|
244
|
-
`
|
|
262
|
+
`Filter`\<`T`\>
|
|
245
263
|
|
|
246
264
|
The query filter to match documents against.
|
|
247
265
|
|
|
266
|
+
##### options?
|
|
267
|
+
|
|
268
|
+
`FindOptions`
|
|
269
|
+
|
|
270
|
+
Optional settings for the command
|
|
271
|
+
|
|
248
272
|
#### Returns
|
|
249
273
|
|
|
250
|
-
`
|
|
274
|
+
`FindCursor`\<`T`\>
|
|
251
275
|
|
|
252
276
|
***
|
|
253
277
|
|
|
254
278
|
### findOne()
|
|
255
279
|
|
|
256
|
-
> **findOne**(`filter`): `Promise`\<`
|
|
280
|
+
> **findOne**(`filter`): `Promise`\<`T` \| `null`\>
|
|
257
281
|
|
|
258
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
282
|
+
Defined in: [src/database/MongoRepository.ts:119](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L119)
|
|
259
283
|
|
|
260
284
|
Returns the first document matching the given filter.
|
|
261
285
|
|
|
@@ -269,15 +293,15 @@ The query filter to match documents against.
|
|
|
269
293
|
|
|
270
294
|
#### Returns
|
|
271
295
|
|
|
272
|
-
`Promise`\<`
|
|
296
|
+
`Promise`\<`T` \| `null`\>
|
|
273
297
|
|
|
274
298
|
***
|
|
275
299
|
|
|
276
300
|
### save()
|
|
277
301
|
|
|
278
|
-
> **save**(`doc`): `Promise`\<`
|
|
302
|
+
> **save**(`doc`): `Promise`\<`T`\>
|
|
279
303
|
|
|
280
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
304
|
+
Defined in: [src/database/MongoRepository.ts:131](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L131)
|
|
281
305
|
|
|
282
306
|
Saves the given document to the collection. If the document has an existing `_id` the stored document is
|
|
283
307
|
replaced (inserting if missing), otherwise the document is inserted and its newly assigned `_id` is set on
|
|
@@ -293,7 +317,7 @@ The document to save.
|
|
|
293
317
|
|
|
294
318
|
#### Returns
|
|
295
319
|
|
|
296
|
-
`Promise`\<`
|
|
320
|
+
`Promise`\<`T`\>
|
|
297
321
|
|
|
298
322
|
The saved document.
|
|
299
323
|
|
|
@@ -301,9 +325,9 @@ The saved document.
|
|
|
301
325
|
|
|
302
326
|
### updateMany()
|
|
303
327
|
|
|
304
|
-
> **updateMany**(`filter`, `update`): `Promise`\<`UpdateResult`\<`
|
|
328
|
+
> **updateMany**(`filter`, `update`, `options?`): `Promise`\<`UpdateResult`\<`T`\>\>
|
|
305
329
|
|
|
306
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
330
|
+
Defined in: [src/database/MongoRepository.ts:157](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L157)
|
|
307
331
|
|
|
308
332
|
Updates all documents matching the given filter with the provided update operations.
|
|
309
333
|
|
|
@@ -321,17 +345,23 @@ The query filter to match documents against.
|
|
|
321
345
|
|
|
322
346
|
The update operations (e.g. `$set`) to apply.
|
|
323
347
|
|
|
348
|
+
##### options?
|
|
349
|
+
|
|
350
|
+
`UpdateOptions`
|
|
351
|
+
|
|
352
|
+
Optional settings for the command
|
|
353
|
+
|
|
324
354
|
#### Returns
|
|
325
355
|
|
|
326
|
-
`Promise`\<`UpdateResult`\<`
|
|
356
|
+
`Promise`\<`UpdateResult`\<`T`\>\>
|
|
327
357
|
|
|
328
358
|
***
|
|
329
359
|
|
|
330
360
|
### updateOne()
|
|
331
361
|
|
|
332
|
-
> **updateOne**(`filter`, `update`): `Promise`\<`UpdateResult`\<`
|
|
362
|
+
> **updateOne**(`filter`, `update`, `options?`): `Promise`\<`UpdateResult`\<`T`\>\>
|
|
333
363
|
|
|
334
|
-
Defined in: [src/database/MongoRepository.ts:
|
|
364
|
+
Defined in: [src/database/MongoRepository.ts:168](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoRepository.ts#L168)
|
|
335
365
|
|
|
336
366
|
Updates the first document matching the given filter with the provided update operations.
|
|
337
367
|
|
|
@@ -349,6 +379,12 @@ The query filter to match documents against.
|
|
|
349
379
|
|
|
350
380
|
The update operations (e.g. `$set`) to apply.
|
|
351
381
|
|
|
382
|
+
##### options?
|
|
383
|
+
|
|
384
|
+
`UpdateOptions`
|
|
385
|
+
|
|
386
|
+
Optional settings for the command
|
|
387
|
+
|
|
352
388
|
#### Returns
|
|
353
389
|
|
|
354
|
-
`Promise`\<`UpdateResult`\<`
|
|
390
|
+
`Promise`\<`UpdateResult`\<`T`\>\>
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MongoSchemaSync
|
|
8
8
|
|
|
9
|
-
Defined in: [src/database/MongoSchemaSync.ts:
|
|
9
|
+
Defined in: [src/database/MongoSchemaSync.ts:40](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoSchemaSync.ts#L40)
|
|
10
10
|
|
|
11
11
|
Performs structure synchronization of MongoDB collections based on the persistence metadata of model classes.
|
|
12
12
|
|
|
13
|
-
For each collection associated with a model class the following operations are performed:
|
|
14
|
-
- The collection is created if it does not already exist.
|
|
15
|
-
- Indexes declared via the `@Index` and `@Unique` decorators are created if missing.
|
|
13
|
+
For each collection associated with a model class the following operations are performed:
|
|
14
|
+
- The collection is created if it does not already exist.
|
|
15
|
+
- Indexes declared via the `@Index` and `@Unique` decorators are created if missing.
|
|
16
16
|
- Existing declared indexes whose definition has changed are dropped and re-created.
|
|
17
17
|
|
|
18
|
-
The synchronization process never drops collections or data, never modifies the built-in `_id_` index, and never
|
|
18
|
+
The synchronization process never drops collections or data, never modifies the built-in `_id_` index, and never
|
|
19
19
|
drops indexes that are not declared by the model class (e.g. shard keys or manually created indexes).
|
|
20
20
|
|
|
21
21
|
## Author
|
|
@@ -28,7 +28,7 @@ Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
|
28
28
|
|
|
29
29
|
> **new MongoSchemaSync**(`db`, `logger?`): `MongoSchemaSync`
|
|
30
30
|
|
|
31
|
-
Defined in: [src/database/MongoSchemaSync.ts:
|
|
31
|
+
Defined in: [src/database/MongoSchemaSync.ts:44](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoSchemaSync.ts#L44)
|
|
32
32
|
|
|
33
33
|
#### Parameters
|
|
34
34
|
|
|
@@ -46,11 +46,41 @@ Defined in: [src/database/MongoSchemaSync.ts:37](https://github.com/rapidrest/se
|
|
|
46
46
|
|
|
47
47
|
## Methods
|
|
48
48
|
|
|
49
|
+
### resolveCollectionInfo()
|
|
50
|
+
|
|
51
|
+
> **resolveCollectionInfo**(`clazz`): `CollectionInfo`
|
|
52
|
+
|
|
53
|
+
Defined in: [src/database/MongoSchemaSync.ts:62](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoSchemaSync.ts#L62)
|
|
54
|
+
|
|
55
|
+
Resolves the entity info of the database collection (or table) that records of the given model class are stored in.
|
|
56
|
+
|
|
57
|
+
The entity info is resolved using the following rules:
|
|
58
|
+
1. The nearest class in the inheritance chain (starting with `clazz` itself) that specifies an explicit
|
|
59
|
+
entity info via the `@Entity(info)` decorator.
|
|
60
|
+
2. Otherwise, the most ancestral class in the inheritance chain that declares its own `@DataStore` binding.
|
|
61
|
+
This ensures that `@ChildEntity` subclasses are stored in the same collection as their parent entity
|
|
62
|
+
(single collection inheritance).
|
|
63
|
+
3. Otherwise, a new info object containing the snake_case form of the class name.
|
|
64
|
+
|
|
65
|
+
#### Parameters
|
|
66
|
+
|
|
67
|
+
##### clazz
|
|
68
|
+
|
|
69
|
+
`any`
|
|
70
|
+
|
|
71
|
+
The model class to resolve the collection name for.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`CollectionInfo`
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
49
79
|
### synchronize()
|
|
50
80
|
|
|
51
81
|
> **synchronize**(`entities`): `Promise`\<`void`\>
|
|
52
82
|
|
|
53
|
-
Defined in: [src/database/MongoSchemaSync.ts:
|
|
83
|
+
Defined in: [src/database/MongoSchemaSync.ts:98](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/database/MongoSchemaSync.ts#L98)
|
|
54
84
|
|
|
55
85
|
Synchronizes the structure of all collections associated with the given model classes.
|
|
56
86
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: NetUtils
|
|
8
8
|
|
|
9
|
-
Defined in: [src/NetUtils.ts:12](https://github.com/rapidrest/service-core/blob/
|
|
9
|
+
Defined in: [src/NetUtils.ts:12](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NetUtils.ts#L12)
|
|
10
10
|
|
|
11
11
|
Provides common utilities and functions for working with networking related problems.
|
|
12
12
|
|
|
@@ -30,7 +30,7 @@ Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
|
30
30
|
|
|
31
31
|
> `static` **getIPAddress**(`urlOrRequest`, `trustedProxies?`): `string` \| `undefined`
|
|
32
32
|
|
|
33
|
-
Defined in: [src/NetUtils.ts:57](https://github.com/rapidrest/service-core/blob/
|
|
33
|
+
Defined in: [src/NetUtils.ts:57](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NetUtils.ts#L57)
|
|
34
34
|
|
|
35
35
|
Extracts the IP address from a given url or HTTP request.
|
|
36
36
|
|
|
@@ -65,7 +65,7 @@ A `string` containing the IP address if found, otherwise `undefined`.
|
|
|
65
65
|
|
|
66
66
|
> `static` **lookupIPAddress**(`url`, `family?`): `Promise`\<`string` \| `undefined`\>
|
|
67
67
|
|
|
68
|
-
Defined in: [src/NetUtils.ts:20](https://github.com/rapidrest/service-core/blob/
|
|
68
|
+
Defined in: [src/NetUtils.ts:20](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NetUtils.ts#L20)
|
|
69
69
|
|
|
70
70
|
Performs DNS lookup of the IP address from a given url.
|
|
71
71
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: NotificationUtils
|
|
8
8
|
|
|
9
|
-
Defined in: [src/NotificationUtils.ts:11](https://github.com/rapidrest/service-core/blob/
|
|
9
|
+
Defined in: [src/NotificationUtils.ts:11](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NotificationUtils.ts#L11)
|
|
10
10
|
|
|
11
11
|
Utility functions for sending push notifications to registered clients.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Jean-Philippe Steinmetz
|
|
|
20
20
|
|
|
21
21
|
> **new NotificationUtils**(`redis`): `NotificationUtils`
|
|
22
22
|
|
|
23
|
-
Defined in: [src/NotificationUtils.ts:20](https://github.com/rapidrest/service-core/blob/
|
|
23
|
+
Defined in: [src/NotificationUtils.ts:20](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NotificationUtils.ts#L20)
|
|
24
24
|
|
|
25
25
|
Initializes the utility using the given redis connection.
|
|
26
26
|
|
|
@@ -42,7 +42,7 @@ The redis connection to publish to.
|
|
|
42
42
|
|
|
43
43
|
> **sendMessage**(`uids`, `type`, `action`, `data`): `void`
|
|
44
44
|
|
|
45
|
-
Defined in: [src/NotificationUtils.ts:32](https://github.com/rapidrest/service-core/blob/
|
|
45
|
+
Defined in: [src/NotificationUtils.ts:32](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/NotificationUtils.ts#L32)
|
|
46
46
|
|
|
47
47
|
Sends a given message to the room or user with the specified uid(s).
|
|
48
48
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: ObjectFactory
|
|
8
8
|
|
|
9
|
-
Defined in: [src/ObjectFactory.ts:21](https://github.com/rapidrest/service-core/blob/
|
|
9
|
+
Defined in: [src/ObjectFactory.ts:21](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/ObjectFactory.ts#L21)
|
|
10
10
|
|
|
11
11
|
The `ObjectFactory` is a manager for creating objects based on registered
|
|
12
12
|
class types. This allows for the tracking of multiple instances of objects
|
|
@@ -26,7 +26,7 @@ Jean-Philippe Steinmetz
|
|
|
26
26
|
|
|
27
27
|
> **new ObjectFactory**(`config?`, `logger?`): `ObjectFactory`
|
|
28
28
|
|
|
29
|
-
Defined in: [src/ObjectFactory.ts:22](https://github.com/rapidrest/service-core/blob/
|
|
29
|
+
Defined in: [src/ObjectFactory.ts:22](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/ObjectFactory.ts#L22)
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
@@ -232,7 +232,7 @@ The object instance associated with the given name if found, otherwise `undefine
|
|
|
232
232
|
|
|
233
233
|
> **initialize**\<`T`\>(`obj`): `Promise`\<`T`\>
|
|
234
234
|
|
|
235
|
-
Defined in: [src/ObjectFactory.ts:30](https://github.com/rapidrest/service-core/blob/
|
|
235
|
+
Defined in: [src/ObjectFactory.ts:30](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/ObjectFactory.ts#L30)
|
|
236
236
|
|
|
237
237
|
Scans the given object for any properties with the
|
|
238
238
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: OpenAPIRoute
|
|
8
8
|
|
|
9
|
-
Defined in: [src/routes/OpenAPIRoute.ts:44](https://github.com/rapidrest/service-core/blob/
|
|
9
|
+
Defined in: [src/routes/OpenAPIRoute.ts:44](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/routes/OpenAPIRoute.ts#L44)
|
|
10
10
|
|
|
11
11
|
The `OpenAPIRoute` provides default routes to expose the service's OpenAPI specification.
|
|
12
12
|
|
|
@@ -34,7 +34,7 @@ Jean-Philippe Steinmetz
|
|
|
34
34
|
|
|
35
35
|
> **getAPIDocs**(): `string`
|
|
36
36
|
|
|
37
|
-
Defined in: [src/routes/OpenAPIRoute.ts:63](https://github.com/rapidrest/service-core/blob/
|
|
37
|
+
Defined in: [src/routes/OpenAPIRoute.ts:63](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/routes/OpenAPIRoute.ts#L63)
|
|
38
38
|
|
|
39
39
|
#### Returns
|
|
40
40
|
|
|
@@ -46,7 +46,7 @@ Defined in: [src/routes/OpenAPIRoute.ts:63](https://github.com/rapidrest/service
|
|
|
46
46
|
|
|
47
47
|
> **getHTML**(): `string`
|
|
48
48
|
|
|
49
|
-
Defined in: [src/routes/OpenAPIRoute.ts:54](https://github.com/rapidrest/service-core/blob/
|
|
49
|
+
Defined in: [src/routes/OpenAPIRoute.ts:54](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/routes/OpenAPIRoute.ts#L54)
|
|
50
50
|
|
|
51
51
|
#### Returns
|
|
52
52
|
|
|
@@ -58,7 +58,7 @@ Defined in: [src/routes/OpenAPIRoute.ts:54](https://github.com/rapidrest/service
|
|
|
58
58
|
|
|
59
59
|
> **getJSON**(): `any`
|
|
60
60
|
|
|
61
|
-
Defined in: [src/routes/OpenAPIRoute.ts:71](https://github.com/rapidrest/service-core/blob/
|
|
61
|
+
Defined in: [src/routes/OpenAPIRoute.ts:71](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/routes/OpenAPIRoute.ts#L71)
|
|
62
62
|
|
|
63
63
|
#### Returns
|
|
64
64
|
|
|
@@ -70,7 +70,7 @@ Defined in: [src/routes/OpenAPIRoute.ts:71](https://github.com/rapidrest/service
|
|
|
70
70
|
|
|
71
71
|
> **getYAML**(): `string`
|
|
72
72
|
|
|
73
|
-
Defined in: [src/routes/OpenAPIRoute.ts:80](https://github.com/rapidrest/service-core/blob/
|
|
73
|
+
Defined in: [src/routes/OpenAPIRoute.ts:80](https://github.com/rapidrest/service-core/blob/33d3655fa6883713f33f0fe6f330eb205671fea1/src/routes/OpenAPIRoute.ts#L80)
|
|
74
74
|
|
|
75
75
|
#### Returns
|
|
76
76
|
|