@xylabs/mongo 5.0.95 → 5.0.97
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/README.md +274 -167
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
# @xylabs/mongo
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XYO TypeScript/JavaScript libraries that access Mongo DB
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Using bun:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
27
33
|
|
|
28
|
-
| Class | Description |
|
|
29
|
-
| ------ | ------ |
|
|
30
|
-
| [BaseMongoSdk](#classes/BaseMongoSdk) | Provides a typed wrapper around common MongoDB collection operations. |
|
|
31
|
-
| [MongoClientWrapper](#classes/MongoClientWrapper) | Manages a shared pool of MongoClient instances, reusing connections by URI. |
|
|
32
34
|
|
|
33
|
-
##
|
|
35
|
+
## License
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
| ------ | ------ |
|
|
37
|
-
| [BaseMongoSdkPublicConfig](#interfaces/BaseMongoSdkPublicConfig) | Public configuration options for the Mongo SDK, safe to expose to clients. |
|
|
38
|
-
| [BaseMongoSdkPrivateConfig](#interfaces/BaseMongoSdkPrivateConfig) | Private configuration options for the Mongo SDK containing connection credentials. |
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
39
38
|
|
|
40
|
-
##
|
|
39
|
+
## Reference
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
| ------ | ------ |
|
|
44
|
-
| [BaseMongoSdkConfig](#type-aliases/BaseMongoSdkConfig) | Combined public and private MongoDB SDK configuration. |
|
|
41
|
+
### packages
|
|
45
42
|
|
|
46
|
-
###
|
|
43
|
+
### mongo
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
### .temp-typedoc
|
|
46
|
+
|
|
47
|
+
### classes
|
|
48
|
+
|
|
49
|
+
### <a id="BaseMongoSdk"></a>BaseMongoSdk
|
|
49
50
|
|
|
50
51
|
[**@xylabs/mongo**](#../README)
|
|
51
52
|
|
|
@@ -55,23 +56,23 @@ Provides a typed wrapper around common MongoDB collection operations.
|
|
|
55
56
|
|
|
56
57
|
## Type Parameters
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
### T
|
|
60
|
+
|
|
61
|
+
`T` *extends* `Document`
|
|
61
62
|
|
|
62
63
|
## Constructors
|
|
63
64
|
|
|
64
65
|
### Constructor
|
|
65
66
|
|
|
66
67
|
```ts
|
|
67
|
-
new BaseMongoSdk<T>(config
|
|
68
|
+
new BaseMongoSdk<T>(config): BaseMongoSdk<T>;
|
|
68
69
|
```
|
|
69
70
|
|
|
70
71
|
### Parameters
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
#### config
|
|
74
|
+
|
|
75
|
+
[`BaseMongoSdkConfig`](#../type-aliases/BaseMongoSdkConfig)
|
|
75
76
|
|
|
76
77
|
### Returns
|
|
77
78
|
|
|
@@ -79,9 +80,13 @@ new BaseMongoSdk<T>(config: BaseMongoSdkConfig): BaseMongoSdk<T>;
|
|
|
79
80
|
|
|
80
81
|
## Properties
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
### config
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
config: BaseMongoSdkConfig;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The MongoDB SDK configuration for this instance.
|
|
85
90
|
|
|
86
91
|
## Accessors
|
|
87
92
|
|
|
@@ -104,16 +109,18 @@ Returns the MongoDB connection URI, either from the config or constructed from i
|
|
|
104
109
|
### deleteMany()
|
|
105
110
|
|
|
106
111
|
```ts
|
|
107
|
-
deleteMany(filter
|
|
112
|
+
deleteMany(filter): Promise<DeleteResult>;
|
|
108
113
|
```
|
|
109
114
|
|
|
110
115
|
Deletes all documents matching the filter.
|
|
111
116
|
|
|
112
117
|
### Parameters
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
#### filter
|
|
120
|
+
|
|
121
|
+
`Filter`\<`T`\>
|
|
122
|
+
|
|
123
|
+
The query filter to match documents for deletion
|
|
117
124
|
|
|
118
125
|
### Returns
|
|
119
126
|
|
|
@@ -124,16 +131,18 @@ Deletes all documents matching the filter.
|
|
|
124
131
|
### deleteOne()
|
|
125
132
|
|
|
126
133
|
```ts
|
|
127
|
-
deleteOne(filter
|
|
134
|
+
deleteOne(filter): Promise<DeleteResult>;
|
|
128
135
|
```
|
|
129
136
|
|
|
130
137
|
Deletes the first document matching the filter.
|
|
131
138
|
|
|
132
139
|
### Parameters
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
#### filter
|
|
142
|
+
|
|
143
|
+
`Filter`\<`T`\>
|
|
144
|
+
|
|
145
|
+
The query filter to match a document for deletion
|
|
137
146
|
|
|
138
147
|
### Returns
|
|
139
148
|
|
|
@@ -144,16 +153,18 @@ Deletes the first document matching the filter.
|
|
|
144
153
|
### find()
|
|
145
154
|
|
|
146
155
|
```ts
|
|
147
|
-
find(filter
|
|
156
|
+
find(filter): Promise<FindCursor<WithId<T>>>;
|
|
148
157
|
```
|
|
149
158
|
|
|
150
159
|
Finds all documents matching the filter and returns a cursor.
|
|
151
160
|
|
|
152
161
|
### Parameters
|
|
153
162
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
163
|
+
#### filter
|
|
164
|
+
|
|
165
|
+
`Filter`\<`T`\>
|
|
166
|
+
|
|
167
|
+
The query filter
|
|
157
168
|
|
|
158
169
|
### Returns
|
|
159
170
|
|
|
@@ -164,16 +175,18 @@ Finds all documents matching the filter and returns a cursor.
|
|
|
164
175
|
### findOne()
|
|
165
176
|
|
|
166
177
|
```ts
|
|
167
|
-
findOne(filter
|
|
178
|
+
findOne(filter): Promise<WithId<T> | null>;
|
|
168
179
|
```
|
|
169
180
|
|
|
170
181
|
Finds a single document matching the filter.
|
|
171
182
|
|
|
172
183
|
### Parameters
|
|
173
184
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
#### filter
|
|
186
|
+
|
|
187
|
+
`Filter`\<`T`\>
|
|
188
|
+
|
|
189
|
+
The query filter
|
|
177
190
|
|
|
178
191
|
### Returns
|
|
179
192
|
|
|
@@ -186,17 +199,24 @@ The matched document, or `null` if not found
|
|
|
186
199
|
### insertMany()
|
|
187
200
|
|
|
188
201
|
```ts
|
|
189
|
-
insertMany(items
|
|
202
|
+
insertMany(items, options?): Promise<InsertManyResult<T>>;
|
|
190
203
|
```
|
|
191
204
|
|
|
192
205
|
Inserts multiple documents into the collection.
|
|
193
206
|
|
|
194
207
|
### Parameters
|
|
195
208
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
209
|
+
#### items
|
|
210
|
+
|
|
211
|
+
`OptionalUnlessRequiredId`\<`T`\>[]
|
|
212
|
+
|
|
213
|
+
The documents to insert
|
|
214
|
+
|
|
215
|
+
#### options?
|
|
216
|
+
|
|
217
|
+
`BulkWriteOptions`
|
|
218
|
+
|
|
219
|
+
Optional bulk write options
|
|
200
220
|
|
|
201
221
|
### Returns
|
|
202
222
|
|
|
@@ -207,17 +227,24 @@ Inserts multiple documents into the collection.
|
|
|
207
227
|
### insertOne()
|
|
208
228
|
|
|
209
229
|
```ts
|
|
210
|
-
insertOne(item
|
|
230
|
+
insertOne(item, options?): Promise<InsertOneResult<T>>;
|
|
211
231
|
```
|
|
212
232
|
|
|
213
233
|
Inserts a single document into the collection.
|
|
214
234
|
|
|
215
235
|
### Parameters
|
|
216
236
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
237
|
+
#### item
|
|
238
|
+
|
|
239
|
+
`OptionalUnlessRequiredId`\<`T`\>
|
|
240
|
+
|
|
241
|
+
The document to insert
|
|
242
|
+
|
|
243
|
+
#### options?
|
|
244
|
+
|
|
245
|
+
`InsertOneOptions`
|
|
246
|
+
|
|
247
|
+
Optional insert options
|
|
221
248
|
|
|
222
249
|
### Returns
|
|
223
250
|
|
|
@@ -229,20 +256,32 @@ Inserts a single document into the collection.
|
|
|
229
256
|
|
|
230
257
|
```ts
|
|
231
258
|
replaceOne(
|
|
232
|
-
filter
|
|
233
|
-
item
|
|
234
|
-
options
|
|
259
|
+
filter,
|
|
260
|
+
item,
|
|
261
|
+
options?): Promise<UpdateResult<T>>;
|
|
235
262
|
```
|
|
236
263
|
|
|
237
264
|
Replaces a single document matching the filter.
|
|
238
265
|
|
|
239
266
|
### Parameters
|
|
240
267
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
268
|
+
#### filter
|
|
269
|
+
|
|
270
|
+
`Filter`\<`T`\>
|
|
271
|
+
|
|
272
|
+
The query filter to match the document
|
|
273
|
+
|
|
274
|
+
#### item
|
|
275
|
+
|
|
276
|
+
`OptionalUnlessRequiredId`\<`T`\>
|
|
277
|
+
|
|
278
|
+
The replacement document
|
|
279
|
+
|
|
280
|
+
#### options?
|
|
281
|
+
|
|
282
|
+
`ReplaceOptions`
|
|
283
|
+
|
|
284
|
+
Optional replace options
|
|
246
285
|
|
|
247
286
|
### Returns
|
|
248
287
|
|
|
@@ -253,17 +292,24 @@ Replaces a single document matching the filter.
|
|
|
253
292
|
### updateOne()
|
|
254
293
|
|
|
255
294
|
```ts
|
|
256
|
-
updateOne(filter
|
|
295
|
+
updateOne(filter, fields): Promise<UpdateResult<T>>;
|
|
257
296
|
```
|
|
258
297
|
|
|
259
298
|
Updates a single document matching the filter without upserting.
|
|
260
299
|
|
|
261
300
|
### Parameters
|
|
262
301
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
302
|
+
#### filter
|
|
303
|
+
|
|
304
|
+
`Filter`\<`T`\>
|
|
305
|
+
|
|
306
|
+
The query filter to match the document
|
|
307
|
+
|
|
308
|
+
#### fields
|
|
309
|
+
|
|
310
|
+
`UpdateFilter`\<`T`\>
|
|
311
|
+
|
|
312
|
+
The update operations to apply
|
|
267
313
|
|
|
268
314
|
### Returns
|
|
269
315
|
|
|
@@ -274,17 +320,24 @@ Updates a single document matching the filter without upserting.
|
|
|
274
320
|
### upsertOne()
|
|
275
321
|
|
|
276
322
|
```ts
|
|
277
|
-
upsertOne(filter
|
|
323
|
+
upsertOne(filter, fields): Promise<UpdateResult<T>>;
|
|
278
324
|
```
|
|
279
325
|
|
|
280
326
|
Updates a single document matching the filter, inserting it if it does not exist.
|
|
281
327
|
|
|
282
328
|
### Parameters
|
|
283
329
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
330
|
+
#### filter
|
|
331
|
+
|
|
332
|
+
`Filter`\<`T`\>
|
|
333
|
+
|
|
334
|
+
The query filter to match the document
|
|
335
|
+
|
|
336
|
+
#### fields
|
|
337
|
+
|
|
338
|
+
`UpdateFilter`\<`T`\>
|
|
339
|
+
|
|
340
|
+
The update operations to apply
|
|
288
341
|
|
|
289
342
|
### Returns
|
|
290
343
|
|
|
@@ -295,22 +348,24 @@ Updates a single document matching the filter, inserting it if it does not exist
|
|
|
295
348
|
### useCollection()
|
|
296
349
|
|
|
297
350
|
```ts
|
|
298
|
-
useCollection<R>(func
|
|
351
|
+
useCollection<R>(func): Promise<R>;
|
|
299
352
|
```
|
|
300
353
|
|
|
301
354
|
Executes a callback with access to the configured MongoDB collection.
|
|
302
355
|
|
|
303
356
|
### Type Parameters
|
|
304
357
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
358
|
+
#### R
|
|
359
|
+
|
|
360
|
+
`R`
|
|
308
361
|
|
|
309
362
|
### Parameters
|
|
310
363
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
364
|
+
#### func
|
|
365
|
+
|
|
366
|
+
(`collection`) => `R` \| `Promise`\<`R`\>
|
|
367
|
+
|
|
368
|
+
A callback receiving the typed collection
|
|
314
369
|
|
|
315
370
|
### Returns
|
|
316
371
|
|
|
@@ -323,22 +378,24 @@ The result of the callback
|
|
|
323
378
|
### useMongo()
|
|
324
379
|
|
|
325
380
|
```ts
|
|
326
|
-
useMongo<R>(func
|
|
381
|
+
useMongo<R>(func): Promise<R>;
|
|
327
382
|
```
|
|
328
383
|
|
|
329
384
|
Executes a callback with a connected MongoClient, handling connection and disconnection.
|
|
330
385
|
|
|
331
386
|
### Type Parameters
|
|
332
387
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
388
|
+
#### R
|
|
389
|
+
|
|
390
|
+
`R`
|
|
336
391
|
|
|
337
392
|
### Parameters
|
|
338
393
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
394
|
+
#### func
|
|
395
|
+
|
|
396
|
+
(`client`) => `R` \| `Promise`\<`R`\>
|
|
397
|
+
|
|
398
|
+
A callback receiving the connected MongoClient
|
|
342
399
|
|
|
343
400
|
### Returns
|
|
344
401
|
|
|
@@ -346,7 +403,7 @@ Executes a callback with a connected MongoClient, handling connection and discon
|
|
|
346
403
|
|
|
347
404
|
The result of the callback
|
|
348
405
|
|
|
349
|
-
|
|
406
|
+
### <a id="MongoClientWrapper"></a>MongoClientWrapper
|
|
350
407
|
|
|
351
408
|
[**@xylabs/mongo**](#../README)
|
|
352
409
|
|
|
@@ -360,18 +417,24 @@ Manages a shared pool of MongoClient instances, reusing connections by URI.
|
|
|
360
417
|
|
|
361
418
|
```ts
|
|
362
419
|
new MongoClientWrapper(
|
|
363
|
-
uri
|
|
364
|
-
maxPoolSize
|
|
365
|
-
closeDelay
|
|
420
|
+
uri,
|
|
421
|
+
maxPoolSize?,
|
|
422
|
+
closeDelay?): MongoClientWrapper;
|
|
366
423
|
```
|
|
367
424
|
|
|
368
425
|
### Parameters
|
|
369
426
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
427
|
+
#### uri
|
|
428
|
+
|
|
429
|
+
`string`
|
|
430
|
+
|
|
431
|
+
#### maxPoolSize?
|
|
432
|
+
|
|
433
|
+
`number`
|
|
434
|
+
|
|
435
|
+
#### closeDelay?
|
|
436
|
+
|
|
437
|
+
`number`
|
|
375
438
|
|
|
376
439
|
### Returns
|
|
377
440
|
|
|
@@ -379,9 +442,13 @@ new MongoClientWrapper(
|
|
|
379
442
|
|
|
380
443
|
## Properties
|
|
381
444
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
445
|
+
### clients
|
|
446
|
+
|
|
447
|
+
```ts
|
|
448
|
+
readonly static clients: Map<string, MongoClientWrapper>;
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Global cache of wrapper instances keyed by connection URI.
|
|
385
452
|
|
|
386
453
|
## Methods
|
|
387
454
|
|
|
@@ -389,20 +456,32 @@ new MongoClientWrapper(
|
|
|
389
456
|
|
|
390
457
|
```ts
|
|
391
458
|
static get(
|
|
392
|
-
uri
|
|
393
|
-
poolSize
|
|
394
|
-
closeDelay
|
|
459
|
+
uri,
|
|
460
|
+
poolSize?,
|
|
461
|
+
closeDelay?): MongoClientWrapper;
|
|
395
462
|
```
|
|
396
463
|
|
|
397
464
|
Gets or creates a cached MongoClientWrapper for the given URI.
|
|
398
465
|
|
|
399
466
|
### Parameters
|
|
400
467
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
468
|
+
#### uri
|
|
469
|
+
|
|
470
|
+
`string`
|
|
471
|
+
|
|
472
|
+
The MongoDB connection URI
|
|
473
|
+
|
|
474
|
+
#### poolSize?
|
|
475
|
+
|
|
476
|
+
`number`
|
|
477
|
+
|
|
478
|
+
Maximum connection pool size
|
|
479
|
+
|
|
480
|
+
#### closeDelay?
|
|
481
|
+
|
|
482
|
+
`number`
|
|
483
|
+
|
|
484
|
+
Delay in milliseconds before closing idle connections
|
|
406
485
|
|
|
407
486
|
### Returns
|
|
408
487
|
|
|
@@ -452,9 +531,9 @@ Initiates a graceful close of the connection.
|
|
|
452
531
|
|
|
453
532
|
`Promise`\<`void`\>
|
|
454
533
|
|
|
455
|
-
### interfaces
|
|
534
|
+
### interfaces
|
|
456
535
|
|
|
457
|
-
|
|
536
|
+
### <a id="BaseMongoSdkPrivateConfig"></a>BaseMongoSdkPrivateConfig
|
|
458
537
|
|
|
459
538
|
[**@xylabs/mongo**](#../README)
|
|
460
539
|
|
|
@@ -464,80 +543,108 @@ Private configuration options for the Mongo SDK containing connection credential
|
|
|
464
543
|
|
|
465
544
|
## Properties
|
|
466
545
|
|
|
467
|
-
|
|
468
|
-
| ------ | ------ | ------ |
|
|
469
|
-
| <a id="dbconnectionstring"></a> `dbConnectionString?` | `string` | A full MongoDB connection string, used instead of individual credential fields. |
|
|
470
|
-
| <a id="dbdomain"></a> `dbDomain?` | `string` | The MongoDB Atlas cluster domain. |
|
|
471
|
-
| <a id="dbname"></a> `dbName?` | `string` | The database name to connect to. |
|
|
472
|
-
| <a id="dbpassword"></a> `dbPassword?` | `string` | The password for MongoDB authentication. |
|
|
473
|
-
| <a id="dbusername"></a> `dbUserName?` | `string` | The username for MongoDB authentication. |
|
|
546
|
+
### dbConnectionString?
|
|
474
547
|
|
|
475
|
-
|
|
548
|
+
```ts
|
|
549
|
+
optional dbConnectionString?: string;
|
|
550
|
+
```
|
|
476
551
|
|
|
477
|
-
|
|
552
|
+
A full MongoDB connection string, used instead of individual credential fields.
|
|
478
553
|
|
|
479
554
|
***
|
|
480
555
|
|
|
481
|
-
|
|
556
|
+
### dbDomain?
|
|
482
557
|
|
|
483
|
-
|
|
558
|
+
```ts
|
|
559
|
+
optional dbDomain?: string;
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
The MongoDB Atlas cluster domain.
|
|
563
|
+
|
|
564
|
+
***
|
|
565
|
+
|
|
566
|
+
### dbName?
|
|
567
|
+
|
|
568
|
+
```ts
|
|
569
|
+
optional dbName?: string;
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
The database name to connect to.
|
|
573
|
+
|
|
574
|
+
***
|
|
575
|
+
|
|
576
|
+
### dbPassword?
|
|
577
|
+
|
|
578
|
+
```ts
|
|
579
|
+
optional dbPassword?: string;
|
|
580
|
+
```
|
|
484
581
|
|
|
485
|
-
|
|
486
|
-
| ------ | ------ | ------ |
|
|
487
|
-
| <a id="closedelay"></a> `closeDelay?` | `number` | Delay in milliseconds before closing idle connections. |
|
|
488
|
-
| <a id="collection"></a> `collection` | `string` | The MongoDB collection name to operate on. |
|
|
489
|
-
| <a id="maxpoolsize"></a> `maxPoolSize?` | `number` | Maximum number of connections in the connection pool. |
|
|
582
|
+
The password for MongoDB authentication.
|
|
490
583
|
|
|
491
|
-
|
|
584
|
+
***
|
|
585
|
+
|
|
586
|
+
### dbUserName?
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
optional dbUserName?: string;
|
|
590
|
+
```
|
|
492
591
|
|
|
493
|
-
|
|
592
|
+
The username for MongoDB authentication.
|
|
593
|
+
|
|
594
|
+
### <a id="BaseMongoSdkPublicConfig"></a>BaseMongoSdkPublicConfig
|
|
494
595
|
|
|
495
596
|
[**@xylabs/mongo**](#../README)
|
|
496
597
|
|
|
497
598
|
***
|
|
498
599
|
|
|
600
|
+
Public configuration options for the Mongo SDK, safe to expose to clients.
|
|
601
|
+
|
|
602
|
+
## Properties
|
|
603
|
+
|
|
604
|
+
### closeDelay?
|
|
605
|
+
|
|
499
606
|
```ts
|
|
500
|
-
|
|
607
|
+
optional closeDelay?: number;
|
|
501
608
|
```
|
|
502
609
|
|
|
503
|
-
|
|
610
|
+
Delay in milliseconds before closing idle connections.
|
|
504
611
|
|
|
612
|
+
***
|
|
505
613
|
|
|
506
|
-
|
|
614
|
+
### collection
|
|
507
615
|
|
|
508
|
-
|
|
616
|
+
```ts
|
|
617
|
+
collection: string;
|
|
618
|
+
```
|
|
509
619
|
|
|
510
|
-
|
|
511
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
512
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
513
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
620
|
+
The MongoDB collection name to operate on.
|
|
514
621
|
|
|
515
|
-
|
|
622
|
+
***
|
|
516
623
|
|
|
517
|
-
|
|
624
|
+
### maxPoolSize?
|
|
518
625
|
|
|
519
|
-
|
|
626
|
+
```ts
|
|
627
|
+
optional maxPoolSize?: number;
|
|
628
|
+
```
|
|
520
629
|
|
|
521
|
-
|
|
630
|
+
Maximum number of connections in the connection pool.
|
|
522
631
|
|
|
523
|
-
|
|
632
|
+
### type-aliases
|
|
524
633
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
[
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
634
|
+
### <a id="BaseMongoSdkConfig"></a>BaseMongoSdkConfig
|
|
635
|
+
|
|
636
|
+
[**@xylabs/mongo**](#../README)
|
|
637
|
+
|
|
638
|
+
***
|
|
639
|
+
|
|
640
|
+
```ts
|
|
641
|
+
type BaseMongoSdkConfig = BaseMongoSdkPublicConfig & BaseMongoSdkPrivateConfig;
|
|
642
|
+
```
|
|
535
643
|
|
|
536
|
-
|
|
537
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/mongo
|
|
644
|
+
Combined public and private MongoDB SDK configuration.
|
|
538
645
|
|
|
539
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/mongo/badge
|
|
540
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/mongo
|
|
541
646
|
|
|
542
|
-
[
|
|
543
|
-
[
|
|
647
|
+
[npm-badge]: https://img.shields.io/npm/v/@xylabs/mongo.svg
|
|
648
|
+
[npm-link]: https://www.npmjs.com/package/@xylabs/mongo
|
|
649
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/mongo.svg
|
|
650
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/mongo",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.97",
|
|
4
4
|
"description": "Base functionality used throughout XYO TypeScript/JavaScript libraries that access Mongo DB",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mongo",
|
|
@@ -33,12 +33,10 @@
|
|
|
33
33
|
"types": "./dist/node/index.d.ts",
|
|
34
34
|
"default": "./dist/node/index.mjs"
|
|
35
35
|
},
|
|
36
|
-
"import": "./dist/node/index.mjs",
|
|
37
36
|
"default": "./dist/node/index.mjs"
|
|
38
37
|
},
|
|
39
38
|
"./package.json": "./package.json"
|
|
40
39
|
},
|
|
41
|
-
"types": "./dist/node/index.d.ts",
|
|
42
40
|
"files": [
|
|
43
41
|
"dist",
|
|
44
42
|
"!**/*.bench.*",
|
|
@@ -47,18 +45,21 @@
|
|
|
47
45
|
"README.md"
|
|
48
46
|
],
|
|
49
47
|
"dependencies": {
|
|
50
|
-
"@xylabs/assert": "~5.0.
|
|
48
|
+
"@xylabs/assert": "~5.0.97"
|
|
51
49
|
},
|
|
52
50
|
"devDependencies": {
|
|
53
|
-
"@xylabs/tsconfig": "~7.
|
|
51
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
54
52
|
"mongodb": "^7.1.1",
|
|
55
53
|
"typescript": "^5",
|
|
56
|
-
"vite": "^8.0.
|
|
57
|
-
"vitest": "^4.1.
|
|
54
|
+
"vite": "^8.0.8",
|
|
55
|
+
"vitest": "^4.1.4"
|
|
58
56
|
},
|
|
59
57
|
"peerDependencies": {
|
|
60
58
|
"mongodb": "^6 || ^7"
|
|
61
59
|
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18"
|
|
62
|
+
},
|
|
62
63
|
"publishConfig": {
|
|
63
64
|
"access": "public"
|
|
64
65
|
}
|