@opra/mongodb 1.26.3 → 1.27.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.
@@ -1,50 +1,47 @@
1
1
  import { ExecutionContext, ServiceBase } from '@opra/core';
2
2
  import mongodb, { type UpdateFilter } from 'mongodb';
3
- import type { Nullish, PartialDTO, RequiredSome, Type } from 'ts-gems';
3
+ import type { DTO, Nullish, PartialDTO, RequiredSome, Type } from 'ts-gems';
4
4
  import { MongoAdapter } from '../adapter/mongo-adapter.js';
5
5
  import type { MongoPatchDTO } from '../types.js';
6
6
  import { MongoEntityService } from './mongo-entity-service.js';
7
7
  /**
8
- *
9
- * @namespace MongoCollectionService
8
+ * Options for MongoCollectionService.
10
9
  */
11
10
  export declare namespace MongoCollectionService {
12
11
  /**
13
- * The constructor options of MongoCollectionService.
14
- *
15
- * @interface Options
16
- * @extends MongoService.Options
12
+ * Configuration options for MongoCollectionService.
17
13
  */
18
14
  interface Options extends MongoEntityService.Options {
15
+ /**
16
+ * Default maximum number of records returned by `findMany`.
17
+ */
19
18
  defaultLimit?: number;
20
19
  }
21
20
  }
22
21
  /**
23
- * @class MongoCollectionService
24
- * @template T - The type of the documents in the collection.
22
+ * Service for managing a collection of entities backed by a MongoDB data source.
23
+ *
24
+ * @template T - The entity type managed by this service.
25
25
  */
26
26
  export declare class MongoCollectionService<T extends mongodb.Document> extends MongoEntityService<T> {
27
27
  /**
28
- * Represents the default limit value for a certain operation.
29
- *
30
- * @type {number}
28
+ * Default maximum number of records returned by `findMany`.
31
29
  */
32
30
  defaultLimit: number;
33
31
  /**
34
- * Constructs a new instance
32
+ * Constructs a new instance.
35
33
  *
36
- * @param {Type | string} dataType - The data type of the array elements.
37
- * @param {MongoCollectionService.Options} [options] - The options for the array service.
38
- * @constructor
34
+ * @param dataType - The entity class or its registered name.
35
+ * @param options - Options for the collection service.
39
36
  */
40
37
  constructor(dataType: Type | string, options?: MongoCollectionService.Options);
41
38
  /**
42
39
  * Create a copy of this instance with given properties and context applied.
43
40
  *
44
- * @param {C | ServiceBase} context - The execution context or service base to associate with this instance.
45
- * @param {Nullish<P>} [overwriteProperties] - An optional object containing properties to overwrite in the current instance.
46
- * @param {Partial<C>} [overwriteContext] - An optional partial context to apply and potentially overwrite parts of the provided execution context.
47
- * @return {this & Required<P>} The current instance with the specified properties and context applied.
41
+ * @param context - The execution context or service base to associate with this instance.
42
+ * @param [overwriteProperties] - An optional object containing properties to overwrite in the current instance.
43
+ * @param [overwriteContext] - An optional partial context to apply and potentially overwrite parts of the provided execution context.
44
+ * @returns The current instance with the specified properties and context applied.
48
45
  * @template P
49
46
  * @template C
50
47
  */
@@ -53,156 +50,208 @@ export declare class MongoCollectionService<T extends mongodb.Document> extends
53
50
  * Asserts the existence of a resource with the given ID.
54
51
  * Throws a ResourceNotFoundError if the resource does not exist.
55
52
  *
56
- * @param {MongoAdapter.AnyId} id - The ID of the resource to assert.
57
- * @param {MongoEntityService.ExistsOptions<T>} [options] - Optional options for checking the existence.
58
- * @returns {Promise<void>} - A Promise that resolves when the resource exists.
59
- * @throws {ResourceNotAvailableError} - If the resource does not exist.
53
+ * @param id - The ID of the resource to assert.
54
+ * @param options - Optional options for checking the existence.
55
+ * @returns A Promise that resolves when the resource exists.
56
+ * @throws {@link ResourceNotAvailableError} - If the resource does not exist.
60
57
  */
61
58
  assert(id: MongoAdapter.AnyId, options?: MongoEntityService.ExistsOptions<T>): Promise<void>;
62
59
  /**
63
60
  * Creates a new document in the MongoDB collection.
64
- * Interceptors will be called before performing db operation
61
+ * Interceptors will be called before performing db operation.
65
62
  *
66
- * @param {PartialDTO<T>} input - The input data for creating the document.
67
- * @param {MongoEntityService.CreateOptions} [options] - The options for creating the document.
68
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created document.
69
- * @throws {Error} if an unknown error occurs while creating the document.
63
+ * @param input - The input data for creating the document.
64
+ * @param options - The options for creating the document.
65
+ * @returns A promise that resolves to the created document.
66
+ * @throws {@link Error} if an unknown error occurs while creating the document.
70
67
  */
71
68
  create(input: PartialDTO<T> | T, options: RequiredSome<MongoEntityService.CreateOptions, 'projection'>): Promise<PartialDTO<T>>;
72
69
  create(input: PartialDTO<T> | T, options?: MongoEntityService.CreateOptions): Promise<T>;
73
70
  /**
74
71
  * Returns the count of documents in the collection based on the provided options.
75
72
  *
76
- * @param {MongoEntityService.CountOptions<T>} options - The options for the count operation.
77
- * @return {Promise<number>} - A promise that resolves to the count of documents in the collection.
73
+ * @param options - The options for the count operation.
74
+ * @returns A promise that resolves to the count of documents in the collection.
78
75
  */
79
76
  count(options?: MongoEntityService.CountOptions<T>): Promise<number>;
80
77
  /**
81
78
  * Deletes a document from the collection.
82
79
  *
83
- * @param {MongoAdapter.AnyId} id - The ID of the document to delete.
84
- * @param {MongoEntityService.DeleteOptions<T>} [options] - Optional delete options.
85
- * @return {Promise<number>} - A Promise that resolves to the number of documents deleted.
80
+ * @param id - The ID of the document to delete.
81
+ * @param [options] - Optional delete options.
82
+ * @returns A Promise that resolves to the number of documents deleted.
86
83
  */
87
84
  delete(id: MongoAdapter.AnyId, options?: MongoEntityService.DeleteOptions<T>): Promise<number>;
88
85
  /**
89
86
  * Deletes multiple documents from the collection that meet the specified filter criteria.
90
87
  *
91
- * @param {MongoEntityService.DeleteManyOptions<T>} options - The options for the delete operation.
92
- * @return {Promise<number>} - A promise that resolves to the number of documents deleted.
88
+ * @param options - The options for the delete operation.
89
+ * @returns A promise that resolves to the number of documents deleted.
93
90
  */
94
91
  deleteMany(options?: MongoEntityService.DeleteManyOptions<T>): Promise<number>;
95
92
  /**
96
93
  * The distinct command returns a list of distinct values for the given key across a collection.
97
- * @param {string} field
98
- * @param {MongoEntityService.DistinctOptions<T>} [options]
94
+ * @param field - The field to get distinct values for.
95
+ * @param [options] - The options for the distinct operation.
99
96
  * @protected
100
97
  */
101
98
  distinct(field: string, options?: MongoEntityService.DistinctOptions<T>): Promise<any[]>;
102
99
  /**
103
100
  * Checks if an object with the given id exists.
104
101
  *
105
- * @param {MongoAdapter.AnyId} id - The id of the object to check.
106
- * @param {MongoEntityService.ExistsOptions<T>} [options] - The options for the query (optional).
107
- * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the object exists or not.
102
+ * @param id - The id of the object to check.
103
+ * @param [options] - The options for the query (optional).
104
+ * @returns A Promise that resolves to a boolean indicating whether the object exists or not.
108
105
  */
109
106
  exists(id: MongoAdapter.AnyId, options?: MongoEntityService.ExistsOptions<T>): Promise<boolean>;
110
107
  /**
111
108
  * Checks if an object with the given arguments exists.
112
109
  *
113
- * @param {MongoEntityService.ExistsOptions} [options] - The options for the query (optional).
114
- * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the object exists or not.
110
+ * @param [options] - The options for the query (optional).
111
+ * @returns A Promise that resolves to a boolean indicating whether the object exists or not.
115
112
  */
116
113
  existsOne(options?: MongoEntityService.ExistsOptions<T>): Promise<boolean>;
117
114
  /**
118
- * Finds a document by its ID.
115
+ * Finds a document by its ID and returns it with the requested projection.
119
116
  *
120
- * @param {MongoAdapter.AnyId} id - The ID of the document.
121
- * @param {MongoEntityService.FindOneOptions<T>} [options] - The options for the find query.
122
- * @return {Promise<PartialDTO<T | undefined>>} - A promise resolving to the found document, or undefined if not found.
117
+ * @param id - The ID of the document to find.
118
+ * @param options - Options including a required `projection`.
119
+ * @returns A promise that resolves to the found document as a partial DTO, or `undefined` if not found.
123
120
  */
124
121
  findById(id: MongoAdapter.AnyId, options: RequiredSome<MongoEntityService.FindOneOptions<T>, 'projection'>): Promise<PartialDTO<T> | undefined>;
122
+ /**
123
+ * Finds a document by its ID and returns the whole DTO.
124
+ *
125
+ * @param id - The ID of the document to find.
126
+ * @param options - Optional query options.
127
+ * @returns A promise that resolves to the found document as a full DTO, or `undefined` if not found.
128
+ */
125
129
  findById(id: MongoAdapter.AnyId, options?: MongoEntityService.FindOneOptions<T>): Promise<T | undefined>;
126
130
  /**
127
131
  * Finds a document in the collection that matches the specified options.
128
132
  *
129
- * @param {MongoEntityService.FindOneOptions<T>} [options] - The options for the query.
130
- * @return {Promise<PartialDTO<T> | undefined>} A promise that resolves with the found document or undefined if no document is found.
133
+ * @param [options] - The options for the query.
134
+ * @returns A promise that resolves with the found document or undefined if no document is found.
135
+ */
136
+ /**
137
+ * Finds the first record matching the given options and returns it with the requested projection.
138
+ *
139
+ * @param options - Options including a required `projection`.
140
+ * @returns A promise that resolves to the found record as a partial DTO, or `undefined` if not found.
131
141
  */
132
142
  findOne(options: RequiredSome<MongoEntityService.FindOneOptions<T>, 'projection'>): Promise<PartialDTO<T> | undefined>;
143
+ /**
144
+ * Finds the first record matching the given options and returns the whole DTO.
145
+ *
146
+ * @param options - Optional query options.
147
+ * @returns A promise that resolves to the found record, or `undefined` if not found.
148
+ */
133
149
  findOne(options?: MongoEntityService.FindOneOptions<T>): Promise<T | undefined>;
134
150
  /**
135
- * Finds multiple documents in the MongoDB collection.
151
+ * Finds multiple documents matching the given options and returns them with the requested projection.
136
152
  *
137
- * @param {MongoEntityService.FindManyOptions<T>} options - The options for the find operation.
138
- * @return A Promise that resolves to an array of partial outputs of type T.
153
+ * @param options - Options including a required `projection`.
154
+ * @returns A promise that resolves to an array of matching documents as partial DTOs.
139
155
  */
140
156
  findMany(options: RequiredSome<MongoEntityService.FindManyOptions<T>, 'projection'>): Promise<PartialDTO<T>[]>;
141
- findMany(options?: MongoEntityService.FindManyOptions<T>): Promise<T[]>;
142
157
  /**
143
- * Finds multiple documents in the collection and returns both records (max limit)
144
- * and total count that matched the given criteria
158
+ * Finds multiple documents matching the given options and returns them as whole DTOs.
159
+ *
160
+ * @param options - Optional query options.
161
+ * @returns A promise that resolves to an array of matching documents as whole DTOs.
162
+ */
163
+ findMany(options?: MongoEntityService.FindManyOptions<T>): Promise<DTO<T>[]>;
164
+ /**
165
+ * Finds multiple documents matching the given options and returns them with the total count.
145
166
  *
146
- * @param {MongoEntityService.FindManyOptions<T>} [options] - The options for the find operation.
147
- * @return A Promise that resolves to an array of partial outputs of type T.
167
+ * @param options - Options including a required `projection`.
168
+ * @returns An object containing the items (as partial DTOs) and the total count.
148
169
  */
149
170
  findManyWithCount(options: RequiredSome<MongoEntityService.FindManyOptions<T>, 'projection'>): Promise<{
150
171
  count: number;
151
172
  items: PartialDTO<T>[];
152
173
  }>;
174
+ /**
175
+ * Finds multiple documents matching the given options and returns them with the total count.
176
+ *
177
+ * @param options - Optional query options.
178
+ * @returns An object containing the items (as full DTOs) and the total count.
179
+ */
153
180
  findManyWithCount(options?: MongoEntityService.FindManyOptions<T>): Promise<{
154
181
  count: number;
155
- items: T[];
182
+ items: DTO<T>[];
156
183
  }>;
157
184
  /**
158
- * Retrieves a document from the collection by its ID. Throws error if not found.
185
+ * Retrieves a document by its ID and returns it with the requested projection.
186
+ * Throws a ResourceNotAvailableError if the document does not exist.
159
187
  *
160
- * @param {MongoAdapter.AnyId} id - The ID of the document to retrieve.
161
- * @param {MongoEntityService.FindOneOptions<T>} [options] - Optional options for the findOne operation.
162
- * @returns {Promise<PartialDTO<T>>} - A promise that resolves to the retrieved document,
163
- * or rejects with a ResourceNotFoundError if the document does not exist.
164
- * @throws {ResourceNotAvailableError} - If the document with the specified ID does not exist.
188
+ * @param id - The ID of the document to retrieve.
189
+ * @param options - Options including a required `projection`.
190
+ * @returns A promise that resolves to the retrieved document as a partial DTO.
191
+ * @throws {@link ResourceNotAvailableError} If the document does not exist.
165
192
  */
166
193
  get(id: MongoAdapter.AnyId, options: RequiredSome<MongoEntityService.FindOneOptions<T>, 'projection'>): Promise<PartialDTO<T>>;
194
+ /**
195
+ * Retrieves a document by its ID and returns the whole DTO.
196
+ * Throws a ResourceNotAvailableError if the document does not exist.
197
+ *
198
+ * @param id - The ID of the document to retrieve.
199
+ * @param options - Optional query options.
200
+ * @returns A promise that resolves to the retrieved document as a full DTO.
201
+ * @throws {@link ResourceNotAvailableError} If the document does not exist.
202
+ */
167
203
  get(id: MongoAdapter.AnyId, options?: MongoEntityService.FindOneOptions<T>): Promise<T>;
168
204
  /**
169
- * Replace a document in the MongoDB collection.
170
- * Interceptors will be called before performing db operation
205
+ * Replaces a document by its ID and returns it with the requested projection.
171
206
  *
172
- * @param {MongoAdapter.AnyId} id - The id of the document to replace.
173
- * @param {PartialDTO<T>} input - The input data
174
- * @param {MongoEntityService.ReplaceOptions} [options] - The options for replacing the document.
175
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the replaced document.
176
- * @throws {Error} if an unknown error occurs while replacing the document.
207
+ * @param id - The ID of the document to replace.
208
+ * @param input - The replacement document data.
209
+ * @param options - Options including a required `projection`.
210
+ * @returns A promise that resolves to the replaced document as a partial DTO, or `undefined` if not found.
177
211
  */
178
212
  replace(id: MongoAdapter.AnyId, input: PartialDTO<T>, options: RequiredSome<MongoEntityService.ReplaceOptions<T>, 'projection'>): Promise<PartialDTO<T>>;
213
+ /**
214
+ * Replaces a document by its ID and returns the whole replaced DTO.
215
+ *
216
+ * @param id - The ID of the document to replace.
217
+ * @param input - The replacement document data.
218
+ * @param options - Optional replace options.
219
+ * @returns A promise that resolves to the replaced document as a full DTO, or `undefined` if not found.
220
+ */
179
221
  replace(id: MongoAdapter.AnyId, input: PartialDTO<T>, options?: MongoEntityService.CreateOptions): Promise<T>;
180
222
  /**
181
- * Updates a document with the given id in the collection.
223
+ * Updates a document by its ID and returns it with the requested projection.
182
224
  *
183
- * @param {MongoAdapter.AnyId} id - The id of the document to update.
184
- * @param {MongoPatchDTO<T>|UpdateFilter<T>} input - The partial input object containing the fields to update.
185
- * @param {MongoEntityService.UpdateOneOptions<T>} [options] - The options for the update operation.
186
- * @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
187
- * undefined if the document was not found.
225
+ * @param id - The ID of the document to update.
226
+ * @param input - The fields to update.
227
+ * @param options - Options including a required `projection`.
228
+ * @returns A promise that resolves to the updated document as a partial DTO, or `undefined` if not found.
188
229
  */
189
230
  update(id: MongoAdapter.AnyId, input: MongoPatchDTO<T> | UpdateFilter<T>, options: RequiredSome<MongoEntityService.UpdateOneOptions<T>, 'projection'>): Promise<PartialDTO<T> | undefined>;
231
+ /**
232
+ * Updates a document by its ID and returns the whole updated DTO.
233
+ *
234
+ * @param id - The ID of the document to update.
235
+ * @param input - The fields to update.
236
+ * @param options - Optional update options.
237
+ * @returns A promise that resolves to the updated document as a full DTO, or `undefined` if not found.
238
+ */
190
239
  update(id: MongoAdapter.AnyId, input: MongoPatchDTO<T> | UpdateFilter<T>, options?: MongoEntityService.UpdateOneOptions<T>): Promise<T | undefined>;
191
240
  /**
192
241
  * Updates a document in the collection with the specified ID.
193
242
  *
194
- * @param {MongoAdapter.AnyId} id - The ID of the document to update.
195
- * @param {MongoPatchDTO<T>|UpdateFilter<T>} input - The partial input data to update the document with.
196
- * @param {MongoEntityService.UpdateOneOptions<T>} [options] - The options for updating the document.
197
- * @returns {Promise<number>} - A promise that resolves to the number of documents modified.
243
+ * @param id - The ID of the document to update.
244
+ * @param input - The partial input data to update the document with.
245
+ * @param [options] - The options for updating the document.
246
+ * @returns A promise that resolves to the number of documents modified.
198
247
  */
199
248
  updateOnly(id: MongoAdapter.AnyId, input: MongoPatchDTO<T> | UpdateFilter<T>, options?: MongoEntityService.UpdateOneOptions<T>): Promise<number>;
200
249
  /**
201
250
  * Updates multiple documents in the collection based on the specified input and options.
202
251
  *
203
- * @param {MongoPatchDTO<T>|UpdateFilter<T>} input - The partial input to update the documents with.
204
- * @param {MongoEntityService.UpdateManyOptions<T>} options - The options for updating the documents.
205
- * @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
252
+ * @param input - The partial input to update the documents with.
253
+ * @param [options] - The options for updating the documents.
254
+ * @returns A promise that resolves to the number of documents matched and modified.
206
255
  */
207
256
  updateMany(input: MongoPatchDTO<T> | UpdateFilter<T>, options?: MongoEntityService.UpdateManyOptions<T>): Promise<number>;
208
257
  }
@@ -2,22 +2,20 @@ import { ResourceNotAvailableError } from '@opra/common';
2
2
  import { MongoAdapter } from '../adapter/mongo-adapter.js';
3
3
  import { MongoEntityService } from './mongo-entity-service.js';
4
4
  /**
5
- * @class MongoCollectionService
6
- * @template T - The type of the documents in the collection.
5
+ * Service for managing a collection of entities backed by a MongoDB data source.
6
+ *
7
+ * @template T - The entity type managed by this service.
7
8
  */
8
9
  export class MongoCollectionService extends MongoEntityService {
9
10
  /**
10
- * Represents the default limit value for a certain operation.
11
- *
12
- * @type {number}
11
+ * Default maximum number of records returned by `findMany`.
13
12
  */
14
13
  defaultLimit;
15
14
  /**
16
- * Constructs a new instance
15
+ * Constructs a new instance.
17
16
  *
18
- * @param {Type | string} dataType - The data type of the array elements.
19
- * @param {MongoCollectionService.Options} [options] - The options for the array service.
20
- * @constructor
17
+ * @param dataType - The entity class or its registered name.
18
+ * @param options - Options for the collection service.
21
19
  */
22
20
  constructor(dataType, options) {
23
21
  super(dataType, options);
@@ -26,10 +24,10 @@ export class MongoCollectionService extends MongoEntityService {
26
24
  /**
27
25
  * Create a copy of this instance with given properties and context applied.
28
26
  *
29
- * @param {C | ServiceBase} context - The execution context or service base to associate with this instance.
30
- * @param {Nullish<P>} [overwriteProperties] - An optional object containing properties to overwrite in the current instance.
31
- * @param {Partial<C>} [overwriteContext] - An optional partial context to apply and potentially overwrite parts of the provided execution context.
32
- * @return {this & Required<P>} The current instance with the specified properties and context applied.
27
+ * @param context - The execution context or service base to associate with this instance.
28
+ * @param [overwriteProperties] - An optional object containing properties to overwrite in the current instance.
29
+ * @param [overwriteContext] - An optional partial context to apply and potentially overwrite parts of the provided execution context.
30
+ * @returns The current instance with the specified properties and context applied.
33
31
  * @template P
34
32
  * @template C
35
33
  */
@@ -40,10 +38,10 @@ export class MongoCollectionService extends MongoEntityService {
40
38
  * Asserts the existence of a resource with the given ID.
41
39
  * Throws a ResourceNotFoundError if the resource does not exist.
42
40
  *
43
- * @param {MongoAdapter.AnyId} id - The ID of the resource to assert.
44
- * @param {MongoEntityService.ExistsOptions<T>} [options] - Optional options for checking the existence.
45
- * @returns {Promise<void>} - A Promise that resolves when the resource exists.
46
- * @throws {ResourceNotAvailableError} - If the resource does not exist.
41
+ * @param id - The ID of the resource to assert.
42
+ * @param options - Optional options for checking the existence.
43
+ * @returns A Promise that resolves when the resource exists.
44
+ * @throws {@link ResourceNotAvailableError} - If the resource does not exist.
47
45
  */
48
46
  async assert(id, options) {
49
47
  if (!(await this.exists(id, options)))
@@ -78,8 +76,8 @@ export class MongoCollectionService extends MongoEntityService {
78
76
  /**
79
77
  * Returns the count of documents in the collection based on the provided options.
80
78
  *
81
- * @param {MongoEntityService.CountOptions<T>} options - The options for the count operation.
82
- * @return {Promise<number>} - A promise that resolves to the count of documents in the collection.
79
+ * @param options - The options for the count operation.
80
+ * @returns A promise that resolves to the count of documents in the collection.
83
81
  */
84
82
  async count(options) {
85
83
  const command = {
@@ -103,9 +101,9 @@ export class MongoCollectionService extends MongoEntityService {
103
101
  /**
104
102
  * Deletes a document from the collection.
105
103
  *
106
- * @param {MongoAdapter.AnyId} id - The ID of the document to delete.
107
- * @param {MongoEntityService.DeleteOptions<T>} [options] - Optional delete options.
108
- * @return {Promise<number>} - A Promise that resolves to the number of documents deleted.
104
+ * @param id - The ID of the document to delete.
105
+ * @param [options] - Optional delete options.
106
+ * @returns A Promise that resolves to the number of documents deleted.
109
107
  */
110
108
  async delete(id, options) {
111
109
  const command = {
@@ -130,8 +128,8 @@ export class MongoCollectionService extends MongoEntityService {
130
128
  /**
131
129
  * Deletes multiple documents from the collection that meet the specified filter criteria.
132
130
  *
133
- * @param {MongoEntityService.DeleteManyOptions<T>} options - The options for the delete operation.
134
- * @return {Promise<number>} - A promise that resolves to the number of documents deleted.
131
+ * @param options - The options for the delete operation.
132
+ * @returns A promise that resolves to the number of documents deleted.
135
133
  */
136
134
  async deleteMany(options) {
137
135
  const command = {
@@ -154,8 +152,8 @@ export class MongoCollectionService extends MongoEntityService {
154
152
  }
155
153
  /**
156
154
  * The distinct command returns a list of distinct values for the given key across a collection.
157
- * @param {string} field
158
- * @param {MongoEntityService.DistinctOptions<T>} [options]
155
+ * @param field - The field to get distinct values for.
156
+ * @param [options] - The options for the distinct operation.
159
157
  * @protected
160
158
  */
161
159
  async distinct(field, options) {
@@ -181,9 +179,9 @@ export class MongoCollectionService extends MongoEntityService {
181
179
  /**
182
180
  * Checks if an object with the given id exists.
183
181
  *
184
- * @param {MongoAdapter.AnyId} id - The id of the object to check.
185
- * @param {MongoEntityService.ExistsOptions<T>} [options] - The options for the query (optional).
186
- * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the object exists or not.
182
+ * @param id - The id of the object to check.
183
+ * @param [options] - The options for the query (optional).
184
+ * @returns A Promise that resolves to a boolean indicating whether the object exists or not.
187
185
  */
188
186
  async exists(id, options) {
189
187
  const command = {
@@ -213,8 +211,8 @@ export class MongoCollectionService extends MongoEntityService {
213
211
  /**
214
212
  * Checks if an object with the given arguments exists.
215
213
  *
216
- * @param {MongoEntityService.ExistsOptions} [options] - The options for the query (optional).
217
- * @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the object exists or not.
214
+ * @param [options] - The options for the query (optional).
215
+ * @returns A Promise that resolves to a boolean indicating whether the object exists or not.
218
216
  */
219
217
  async existsOne(options) {
220
218
  return !!(await this.findOne({ ...options, projection: ['_id'] }));
@@ -356,10 +354,10 @@ export class MongoCollectionService extends MongoEntityService {
356
354
  /**
357
355
  * Updates a document in the collection with the specified ID.
358
356
  *
359
- * @param {MongoAdapter.AnyId} id - The ID of the document to update.
360
- * @param {MongoPatchDTO<T>|UpdateFilter<T>} input - The partial input data to update the document with.
361
- * @param {MongoEntityService.UpdateOneOptions<T>} [options] - The options for updating the document.
362
- * @returns {Promise<number>} - A promise that resolves to the number of documents modified.
357
+ * @param id - The ID of the document to update.
358
+ * @param input - The partial input data to update the document with.
359
+ * @param [options] - The options for updating the document.
360
+ * @returns A promise that resolves to the number of documents modified.
363
361
  */
364
362
  async updateOnly(id, input, options) {
365
363
  const isUpdateFilter = Array.isArray(input) || !!Object.keys(input).find(x => x.startsWith('$'));
@@ -387,9 +385,9 @@ export class MongoCollectionService extends MongoEntityService {
387
385
  /**
388
386
  * Updates multiple documents in the collection based on the specified input and options.
389
387
  *
390
- * @param {MongoPatchDTO<T>|UpdateFilter<T>} input - The partial input to update the documents with.
391
- * @param {MongoEntityService.UpdateManyOptions<T>} options - The options for updating the documents.
392
- * @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
388
+ * @param input - The partial input to update the documents with.
389
+ * @param [options] - The options for updating the documents.
390
+ * @returns A promise that resolves to the number of documents matched and modified.
393
391
  */
394
392
  async updateMany(input, options) {
395
393
  const isUpdateFilter = Array.isArray(input) || !!Object.keys(input).find(x => x.startsWith('$'));