@opra/mongodb 0.33.3 → 0.33.5
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/cjs/mongo-array-service.js +9 -0
- package/cjs/mongo-collection-service.js +84 -22
- package/cjs/mongo-service.js +71 -66
- package/esm/mongo-array-service.js +9 -0
- package/esm/mongo-collection-service.js +84 -22
- package/esm/mongo-service.js +71 -66
- package/package.json +3 -3
- package/types/mongo-array-service.d.ts +17 -10
- package/types/mongo-collection-service.d.ts +41 -25
- package/types/mongo-service.d.ts +53 -70
|
@@ -30,6 +30,7 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
30
30
|
$documentFilter?: FilterInput | ((args: {
|
|
31
31
|
crud: MongoService.CrudOp;
|
|
32
32
|
method: string;
|
|
33
|
+
byId: boolean;
|
|
33
34
|
documentId?: AnyId;
|
|
34
35
|
input?: Record<string, any>;
|
|
35
36
|
options?: Record<string, any>;
|
|
@@ -37,19 +38,21 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
37
38
|
/**
|
|
38
39
|
* Interceptor function for handling callback execution with provided arguments.
|
|
39
40
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
41
|
+
* @param callback - The callback function to be intercepted.
|
|
42
|
+
* @param args - The arguments object containing the following properties:
|
|
43
|
+
* @param crud - The CRUD operation type.
|
|
44
|
+
* @param method - The method name.
|
|
45
|
+
* @param byId - True if current operation affects byId records (updateMany, deleteMany etc)
|
|
46
|
+
* @param documentId - The document ID (optional).
|
|
47
|
+
* @param input - The input object (optional).
|
|
48
|
+
* @param options - Additional options (optional).
|
|
49
|
+
* @param _this - The reference to the current object.
|
|
50
|
+
* @returns - The promise that resolves to the result of the callback execution.
|
|
49
51
|
*/
|
|
50
52
|
$interceptor?: (callback: () => any, args: {
|
|
51
53
|
crud: MongoService.CrudOp;
|
|
52
54
|
method: string;
|
|
55
|
+
byId: boolean;
|
|
53
56
|
documentId?: AnyId;
|
|
54
57
|
input?: Record<string, any>;
|
|
55
58
|
options?: Record<string, any>;
|
|
@@ -81,7 +84,7 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
81
84
|
* @throws {Error} if an unknown error occurs while creating the document.
|
|
82
85
|
*/
|
|
83
86
|
create(input: PartialDTO<T>, options?: MongoCollectionService.CreateOptions): Promise<PartialDTO<T>>;
|
|
84
|
-
protected _create(input: PartialDTO<T>, options
|
|
87
|
+
protected _create(input: PartialDTO<T>, options?: MongoCollectionService.CreateOptions): Promise<PartialDTO<T>>;
|
|
85
88
|
/**
|
|
86
89
|
* Returns the count of documents in the collection based on the provided options.
|
|
87
90
|
*
|
|
@@ -107,6 +110,8 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
107
110
|
*/
|
|
108
111
|
deleteMany(options?: MongoCollectionService.DeleteManyOptions<T>): Promise<number>;
|
|
109
112
|
protected _deleteMany(options?: MongoCollectionService.DeleteManyOptions<T>): Promise<number>;
|
|
113
|
+
distinct(field: string, options?: MongoCollectionService.DistinctOptions<T>): Promise<any[]>;
|
|
114
|
+
protected _distinct(field: string, options?: MongoCollectionService.DistinctOptions<T>): Promise<any[]>;
|
|
110
115
|
/**
|
|
111
116
|
* Checks if an object with the given id exists.
|
|
112
117
|
*
|
|
@@ -175,8 +180,8 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
175
180
|
* @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
|
|
176
181
|
* undefined if the document was not found.
|
|
177
182
|
*/
|
|
178
|
-
update(id: AnyId, input: PatchDTO<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<PartialDTO<T> | undefined>;
|
|
179
|
-
protected _update(id: AnyId, input: PatchDTO<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<PartialDTO<T> | undefined>;
|
|
183
|
+
update(id: AnyId, input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<PartialDTO<T> | undefined>;
|
|
184
|
+
protected _update(id: AnyId, input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<PartialDTO<T> | undefined>;
|
|
180
185
|
/**
|
|
181
186
|
* Updates a document in the collection with the specified ID.
|
|
182
187
|
*
|
|
@@ -185,8 +190,8 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
185
190
|
* @param {MongoCollectionService.UpdateOptions<T>} options - The options for updating the document.
|
|
186
191
|
* @returns {Promise<number>} - A promise that resolves to the number of documents modified.
|
|
187
192
|
*/
|
|
188
|
-
updateOnly(id: AnyId, input: PatchDTO<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<number>;
|
|
189
|
-
protected _updateOnly(id: AnyId, input: PatchDTO<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<number>;
|
|
193
|
+
updateOnly(id: AnyId, input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<number>;
|
|
194
|
+
protected _updateOnly(id: AnyId, input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateOptions<T>): Promise<number>;
|
|
190
195
|
/**
|
|
191
196
|
* Updates multiple documents in the collection based on the specified input and options.
|
|
192
197
|
*
|
|
@@ -194,8 +199,8 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
194
199
|
* @param {MongoCollectionService.UpdateManyOptions<T>} options - The options for updating the documents.
|
|
195
200
|
* @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
|
|
196
201
|
*/
|
|
197
|
-
updateMany(input: PatchDTO<T>, options?: MongoCollectionService.UpdateManyOptions<T>): Promise<number>;
|
|
198
|
-
protected _updateMany(input: PatchDTO<T>, options?: MongoCollectionService.UpdateManyOptions<T>): Promise<number>;
|
|
202
|
+
updateMany(input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateManyOptions<T>): Promise<number>;
|
|
203
|
+
protected _updateMany(input: PatchDTO<T> | mongodb.UpdateFilter<T>, options?: MongoCollectionService.UpdateManyOptions<T>): Promise<number>;
|
|
199
204
|
/**
|
|
200
205
|
* Generates an ID.
|
|
201
206
|
*
|
|
@@ -214,6 +219,7 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
214
219
|
protected _getDocumentFilter(args: {
|
|
215
220
|
crud: MongoService.CrudOp;
|
|
216
221
|
method: string;
|
|
222
|
+
byId: boolean;
|
|
217
223
|
documentId?: AnyId;
|
|
218
224
|
input?: Object;
|
|
219
225
|
options?: Record<string, any>;
|
|
@@ -221,6 +227,7 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
|
|
|
221
227
|
protected _intercept(callback: (...args: any[]) => any, args: {
|
|
222
228
|
crud: MongoService.CrudOp;
|
|
223
229
|
method: string;
|
|
230
|
+
byId: boolean;
|
|
224
231
|
documentId?: AnyId;
|
|
225
232
|
input?: Object;
|
|
226
233
|
options?: Record<string, any>;
|
|
@@ -244,7 +251,7 @@ export declare namespace MongoCollectionService {
|
|
|
244
251
|
interceptor?: MongoCollectionService<any>['$interceptor'];
|
|
245
252
|
}
|
|
246
253
|
/**
|
|
247
|
-
* Represents options for
|
|
254
|
+
* Represents options for "create" operation
|
|
248
255
|
*
|
|
249
256
|
* @interface
|
|
250
257
|
*/
|
|
@@ -254,7 +261,7 @@ export declare namespace MongoCollectionService {
|
|
|
254
261
|
include?: string[];
|
|
255
262
|
}
|
|
256
263
|
/**
|
|
257
|
-
* Represents options for
|
|
264
|
+
* Represents options for "count" operation
|
|
258
265
|
*
|
|
259
266
|
* @interface
|
|
260
267
|
* @template T - The type of the document.
|
|
@@ -263,7 +270,7 @@ export declare namespace MongoCollectionService {
|
|
|
263
270
|
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
264
271
|
}
|
|
265
272
|
/**
|
|
266
|
-
* Represents options for
|
|
273
|
+
* Represents options for "delete" operation
|
|
267
274
|
*
|
|
268
275
|
* @interface
|
|
269
276
|
* @template T - The type of the document.
|
|
@@ -272,7 +279,7 @@ export declare namespace MongoCollectionService {
|
|
|
272
279
|
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
273
280
|
}
|
|
274
281
|
/**
|
|
275
|
-
* Represents options for
|
|
282
|
+
* Represents options for "deleteMany" operation
|
|
276
283
|
*
|
|
277
284
|
* @interface
|
|
278
285
|
* @template T - The type of the document.
|
|
@@ -281,7 +288,16 @@ export declare namespace MongoCollectionService {
|
|
|
281
288
|
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
282
289
|
}
|
|
283
290
|
/**
|
|
284
|
-
* Represents options for
|
|
291
|
+
* Represents options for "distinct" operation
|
|
292
|
+
*
|
|
293
|
+
* @interface
|
|
294
|
+
* @template T - The type of the document.
|
|
295
|
+
*/
|
|
296
|
+
interface DistinctOptions<T> extends mongodb.DistinctOptions {
|
|
297
|
+
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Represents options for "findOne" operation
|
|
285
301
|
*
|
|
286
302
|
* @interface
|
|
287
303
|
* @template T - The type of the document.
|
|
@@ -289,7 +305,7 @@ export declare namespace MongoCollectionService {
|
|
|
289
305
|
interface FindOneOptions<T = any> extends StrictOmit<FindManyOptions<T>, 'count' | 'limit'> {
|
|
290
306
|
}
|
|
291
307
|
/**
|
|
292
|
-
* Represents options for
|
|
308
|
+
* Represents options for "findMany" operation
|
|
293
309
|
*
|
|
294
310
|
* @interface
|
|
295
311
|
* @template T - The type of the document.
|
|
@@ -305,7 +321,7 @@ export declare namespace MongoCollectionService {
|
|
|
305
321
|
count?: boolean;
|
|
306
322
|
}
|
|
307
323
|
/**
|
|
308
|
-
* Represents options for
|
|
324
|
+
* Represents options for "update" operation
|
|
309
325
|
*
|
|
310
326
|
* @interface
|
|
311
327
|
* @template T - The type of the document.
|
|
@@ -317,7 +333,7 @@ export declare namespace MongoCollectionService {
|
|
|
317
333
|
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
318
334
|
}
|
|
319
335
|
/**
|
|
320
|
-
* Represents options for
|
|
336
|
+
* Represents options for "updateMany" operation
|
|
321
337
|
*
|
|
322
338
|
* @interface
|
|
323
339
|
* @template T - The type of the document.
|
|
@@ -326,7 +342,7 @@ export declare namespace MongoCollectionService {
|
|
|
326
342
|
filter?: mongodb.Filter<T> | OpraCommon.OpraFilter.Ast | string;
|
|
327
343
|
}
|
|
328
344
|
/**
|
|
329
|
-
* Represents options for
|
|
345
|
+
* Represents options for "exists" operation
|
|
330
346
|
*
|
|
331
347
|
* @interface
|
|
332
348
|
*/
|
package/types/mongo-service.d.ts
CHANGED
|
@@ -15,76 +15,63 @@ export declare class MongoService<T extends mongodb.Document> extends ApiService
|
|
|
15
15
|
protected _dataType: Type | string;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the name of a collection in MongoDB
|
|
18
|
-
*
|
|
19
|
-
* @type {string | Function} collectionName
|
|
20
18
|
*/
|
|
21
19
|
collectionName?: string | ((_this: any) => string);
|
|
22
20
|
/**
|
|
23
21
|
* Represents the name of a resource.
|
|
24
|
-
*
|
|
25
22
|
* @type {string}
|
|
26
23
|
*/
|
|
27
24
|
resourceName?: string | ((_this: any) => string);
|
|
28
25
|
/**
|
|
29
26
|
* Represents a MongoDB database object.
|
|
30
|
-
* @type {mongodb.Db | Function}
|
|
31
27
|
*/
|
|
32
28
|
db?: mongodb.Db | ((_this: any) => mongodb.Db);
|
|
33
29
|
/**
|
|
34
30
|
* Represents a MongoDB ClientSession.
|
|
35
|
-
*
|
|
36
|
-
* @type {mongodb.ClientSession}
|
|
37
31
|
*/
|
|
38
32
|
session?: mongodb.ClientSession | ((_this: any) => mongodb.ClientSession);
|
|
39
33
|
/**
|
|
40
34
|
* Generates a new id for new inserting Document.
|
|
41
35
|
*
|
|
42
36
|
* @protected
|
|
43
|
-
* @returns {AnyId} A new instance of AnyId.
|
|
44
37
|
*/
|
|
45
38
|
$idGenerator?: (_this: any) => AnyId;
|
|
46
39
|
/**
|
|
47
40
|
* Callback function for handling errors.
|
|
48
41
|
*
|
|
49
42
|
* @param {unknown} error - The error object.
|
|
50
|
-
* @param
|
|
51
|
-
* @return {void|Promise<void>} - A void value or a promise that resolves to void.
|
|
43
|
+
* @param _this - The context object.
|
|
52
44
|
*/
|
|
53
45
|
$onError?: (error: unknown, _this: any) => void | Promise<void>;
|
|
54
46
|
/**
|
|
55
47
|
* Constructs a new instance
|
|
56
48
|
*
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
49
|
+
* @param dataType - The data type of the array elements.
|
|
50
|
+
* @param [options] - The options for the array service.
|
|
59
51
|
* @constructor
|
|
60
52
|
*/
|
|
61
53
|
constructor(dataType: Type | string, options?: MongoService.Options);
|
|
62
54
|
/**
|
|
63
55
|
* Retrieves the data type of the document
|
|
64
56
|
*
|
|
65
|
-
* @returns {ComplexType} The complex data type of the field.
|
|
66
57
|
* @throws {NotAcceptableError} If the data type is not a ComplexType.
|
|
67
58
|
*/
|
|
68
59
|
getDataType(): ComplexType;
|
|
69
60
|
/**
|
|
70
61
|
* Retrieves the encoder for the specified operation.
|
|
71
62
|
*
|
|
72
|
-
* @param
|
|
73
|
-
* @returns {IsObject.Validator<T>} - The encoder for the specified operation.
|
|
63
|
+
* @param operation - The operation to retrieve the encoder for. Valid values are 'create' and 'update'.
|
|
74
64
|
*/
|
|
75
65
|
getEncoder(operation: 'create' | 'update'): IsObject.Validator<T>;
|
|
76
66
|
/**
|
|
77
67
|
* Retrieves the decoder.
|
|
78
|
-
*
|
|
79
|
-
* @returns {IsObject.Validator<T>} - The encoder for the specified operation.
|
|
80
68
|
*/
|
|
81
69
|
getDecoder(): IsObject.Validator<T>;
|
|
82
70
|
/**
|
|
83
71
|
* Executes the provided function within a transaction.
|
|
84
72
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @returns {Promise<any>} - A promise that resolves with the result of the function execution within the transaction.
|
|
73
|
+
* @param callback - The function to be executed within the transaction.
|
|
74
|
+
* @param [options] - Optional options for the transaction.
|
|
88
75
|
*/
|
|
89
76
|
withTransaction(callback: WithTransactionCallback, options?: TransactionOptions): Promise<any>;
|
|
90
77
|
/**
|
|
@@ -92,103 +79,101 @@ export declare class MongoService<T extends mongodb.Document> extends ApiService
|
|
|
92
79
|
* one will be added to each of the documents missing it by the driver, mutating the document. This behavior
|
|
93
80
|
* can be overridden by setting the **forceServerObjectId** flag.
|
|
94
81
|
*
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @returns {Promise<mongodb.InsertOneWriteOpResult<mongodb.OptionalId<T>>>} - A promise that resolves with the result of the insert operation.
|
|
82
|
+
* @param doc - The document to insert
|
|
83
|
+
* @param options - Optional settings for the command
|
|
98
84
|
* @protected
|
|
99
85
|
*/
|
|
100
86
|
protected __insertOne(doc: mongodb.OptionalUnlessRequiredId<T>, options?: mongodb.InsertOneOptions): Promise<mongodb.InsertOneResult<T>>;
|
|
101
87
|
/**
|
|
102
88
|
* Gets the number of documents matching the filter.
|
|
103
89
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns {Promise<number>} - The number of documents matching the filter.
|
|
90
|
+
* @param filter - The filter used to match documents.
|
|
91
|
+
* @param options - The options for counting documents.
|
|
107
92
|
* @protected
|
|
108
93
|
*/
|
|
109
94
|
protected __countDocuments(filter?: mongodb.Filter<T>, options?: mongodb.CountOptions): Promise<number>;
|
|
110
95
|
/**
|
|
111
96
|
* Delete a document from a collection
|
|
112
97
|
*
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @
|
|
98
|
+
* @param filter - The filter used to select the document to remove
|
|
99
|
+
* @param options - Optional settings for the command
|
|
100
|
+
* @protected
|
|
116
101
|
*/
|
|
117
102
|
protected __deleteOne(filter?: mongodb.Filter<T>, options?: mongodb.DeleteOptions): Promise<mongodb.DeleteResult>;
|
|
118
103
|
/**
|
|
119
|
-
*
|
|
104
|
+
* Delete multiple documents from a collection
|
|
120
105
|
*
|
|
121
|
-
* @param
|
|
122
|
-
*
|
|
123
|
-
* @param {mongodb.DeleteOptions} [options] - The options for the delete operation.
|
|
124
|
-
* @returns {Promise<mongodb.DeleteResult>} A promise that resolves with the delete result object.
|
|
106
|
+
* @param filter - The filter used to select the documents to remove
|
|
107
|
+
* @param options - Optional settings for the command
|
|
125
108
|
* @protected
|
|
126
109
|
*/
|
|
127
110
|
protected __deleteMany(filter?: mongodb.Filter<T>, options?: mongodb.DeleteOptions): Promise<mongodb.DeleteResult>;
|
|
128
111
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
112
|
+
* Gets the number of documents matching the filter.
|
|
113
|
+
*
|
|
114
|
+
* @param field - Field of the document to find distinct values for
|
|
115
|
+
* @param filter - The filter for filtering the set of documents to which we apply the distinct filter.
|
|
116
|
+
* @param options - Optional settings for the command
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
protected __distinct(field: string, filter?: mongodb.Filter<T>, options?: mongodb.DistinctOptions): Promise<any[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Execute an aggregation framework pipeline against the collection, needs MongoDB \>= 2.2
|
|
131
122
|
*
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @returns {Promise<mongodb.ChangeStream<T>>} - A promise that resolves to a Change Stream that represents the result of the aggregation.
|
|
123
|
+
* @param pipeline - An array of aggregation pipelines to execute
|
|
124
|
+
* @param options - Optional settings for the command
|
|
135
125
|
* @protected
|
|
136
126
|
*/
|
|
137
127
|
protected __aggregate(pipeline?: mongodb.Document[], options?: mongodb.AggregateOptions): Promise<mongodb.AggregationCursor<T>>;
|
|
138
128
|
/**
|
|
139
129
|
* Fetches the first document that matches the filter
|
|
140
130
|
*
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
131
|
+
* @param filter - Query for find Operation
|
|
132
|
+
* @param options - Optional settings for the command
|
|
143
133
|
* @protected
|
|
144
|
-
* @returns {Promise<PartialDTO<T> | undefined>} - A promise that resolves to the first matching document, or undefined if no match is found
|
|
145
134
|
*/
|
|
146
135
|
protected __findOne(filter: mongodb.Filter<T>, options?: mongodb.FindOptions): Promise<PartialDTO<T> | undefined>;
|
|
147
136
|
/**
|
|
148
|
-
* Creates a cursor for a filter that can be used to iterate over results from MongoDB
|
|
137
|
+
* Creates a cursor for a filter that can be used to iterate over results from MongoDB
|
|
149
138
|
*
|
|
150
|
-
* @param
|
|
151
|
-
*
|
|
152
|
-
* @
|
|
139
|
+
* @param filter - The filter predicate. If unspecified,
|
|
140
|
+
* then all documents in the collection will match the predicate
|
|
141
|
+
* @param options - Optional settings for the command
|
|
153
142
|
* @protected
|
|
154
143
|
*/
|
|
155
144
|
protected __find(filter: mongodb.Filter<T>, options?: mongodb.FindOptions): Promise<mongodb.FindCursor<T>>;
|
|
156
145
|
/**
|
|
157
|
-
* Update a single document in a collection
|
|
146
|
+
* Update a single document in a collection
|
|
158
147
|
*
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
161
|
-
* @param
|
|
148
|
+
* @param filter - The filter used to select the document to update
|
|
149
|
+
* @param update - The update operations to be applied to the document
|
|
150
|
+
* @param options - Optional settings for the command
|
|
162
151
|
* @protected
|
|
163
|
-
* @returns {Promise<mongodb.UpdateResult>} - A promise that resolves to the result of the update operation.
|
|
164
152
|
*/
|
|
165
153
|
protected __updateOne(filter: mongodb.Filter<T>, update: mongodb.UpdateFilter<T>, options?: mongodb.UpdateOptions): Promise<mongodb.UpdateResult<T>>;
|
|
166
154
|
/**
|
|
167
155
|
* Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation.
|
|
168
156
|
*
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @returns {Promise<T | null>} - A promise that resolves to the updated document or null if no document matched the filter.
|
|
157
|
+
* @param filter - The filter used to select the document to update
|
|
158
|
+
* @param update - Update operations to be performed on the document
|
|
159
|
+
* @param options - Optional settings for the command
|
|
173
160
|
* @protected
|
|
174
161
|
*/
|
|
175
|
-
protected __findOneAndUpdate(filter: mongodb.Filter<T>,
|
|
162
|
+
protected __findOneAndUpdate(filter: mongodb.Filter<T>, update: mongodb.UpdateFilter<T>, options?: mongodb.FindOneAndUpdateOptions): Promise<mongodb.WithId<T> | null>;
|
|
176
163
|
/**
|
|
177
|
-
* Update multiple documents in a collection
|
|
164
|
+
* Update multiple documents in a collection
|
|
178
165
|
*
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @param
|
|
182
|
-
* @return {Promise<mongodb.UpdateResult>} - A Promise that resolves to the result of the update operation.
|
|
166
|
+
* @param filter - The filter used to select the documents to update
|
|
167
|
+
* @param update - The update operations to be applied to the documents
|
|
168
|
+
* @param options - Optional settings for the command
|
|
183
169
|
* @protected
|
|
184
170
|
*/
|
|
185
|
-
protected __updateMany(filter: mongodb.Filter<T>,
|
|
171
|
+
protected __updateMany(filter: mongodb.Filter<T>, update: mongodb.UpdateFilter<T> | Partial<T>, options?: StrictOmit<mongodb.UpdateOptions, 'upsert'>): Promise<mongodb.UpdateResult<T>>;
|
|
186
172
|
/**
|
|
187
173
|
* Retrieves the database connection.
|
|
188
174
|
*
|
|
189
175
|
* @protected
|
|
190
176
|
*
|
|
191
|
-
* @returns {Promise<mongodb.Db>} The database connection.
|
|
192
177
|
* @throws {Error} If the context or database is not set.
|
|
193
178
|
*/
|
|
194
179
|
protected getDatabase(): mongodb.Db;
|
|
@@ -197,23 +182,21 @@ export declare class MongoService<T extends mongodb.Document> extends ApiService
|
|
|
197
182
|
*
|
|
198
183
|
* @protected
|
|
199
184
|
*
|
|
200
|
-
* @returns {Promise<mongodb.ClientSession>} The database connection.
|
|
201
185
|
* @throws {Error} If the context or database is not set.
|
|
202
186
|
*/
|
|
203
187
|
protected getSession(): mongodb.ClientSession | undefined;
|
|
204
188
|
/**
|
|
205
189
|
* Retrieves a MongoDB collection from the given database.
|
|
206
190
|
*
|
|
207
|
-
* @param
|
|
191
|
+
* @param db - The MongoDB database.
|
|
208
192
|
* @protected
|
|
209
|
-
* @returns {Promise<mongodb.Collection<T>>} A promise that resolves to the MongoDB collection.
|
|
210
193
|
*/
|
|
211
194
|
protected getCollection(db: mongodb.Db): Promise<mongodb.Collection<T>>;
|
|
212
195
|
/**
|
|
213
196
|
* Retrieves the collection name.
|
|
214
197
|
*
|
|
215
198
|
* @protected
|
|
216
|
-
* @returns
|
|
199
|
+
* @returns The collection name.
|
|
217
200
|
* @throws {Error} If the collection name is not defined.
|
|
218
201
|
*/
|
|
219
202
|
getCollectionName(): string;
|
|
@@ -221,23 +204,23 @@ export declare class MongoService<T extends mongodb.Document> extends ApiService
|
|
|
221
204
|
* Retrieves the resource name.
|
|
222
205
|
*
|
|
223
206
|
* @protected
|
|
224
|
-
* @returns {string} The
|
|
207
|
+
* @returns {string} The resource name.
|
|
225
208
|
* @throws {Error} If the collection name is not defined.
|
|
226
209
|
*/
|
|
227
210
|
getResourceName(): string;
|
|
228
211
|
/**
|
|
229
212
|
* Generates an encoder for the specified operation.
|
|
230
213
|
*
|
|
231
|
-
* @param
|
|
214
|
+
* @param operation - The operation to generate the encoder for. Must be either 'create' or 'update'.
|
|
232
215
|
* @protected
|
|
233
|
-
* @returns
|
|
216
|
+
* @returns - The generated encoder for the specified operation.
|
|
234
217
|
*/
|
|
235
218
|
protected _generateEncoder(operation: 'create' | 'update'): IsObject.Validator<T>;
|
|
236
219
|
/**
|
|
237
220
|
* Generates an encoder for the specified operation.
|
|
238
221
|
*
|
|
239
222
|
* @protected
|
|
240
|
-
* @returns
|
|
223
|
+
* @returns - The generated encoder for the specified operation.
|
|
241
224
|
*/
|
|
242
225
|
protected _generateDecoder(): IsObject.Validator<T>;
|
|
243
226
|
}
|