@xylabs/mongo 5.0.83 → 5.0.86
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 +162 -184
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XYO TypeScript/JavaScript libraries that access Mongo DB
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/mongo**
|
|
@@ -23,17 +25,23 @@ Base functionality used throughout XYO TypeScript/JavaScript libraries that acce
|
|
|
23
25
|
|
|
24
26
|
## Classes
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
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. |
|
|
28
32
|
|
|
29
33
|
## Interfaces
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
| Interface | Description |
|
|
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. |
|
|
33
39
|
|
|
34
40
|
## Type Aliases
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
| Type Alias | Description |
|
|
43
|
+
| ------ | ------ |
|
|
44
|
+
| [BaseMongoSdkConfig](#type-aliases/BaseMongoSdkConfig) | Combined public and private MongoDB SDK configuration. |
|
|
37
45
|
|
|
38
46
|
### classes
|
|
39
47
|
|
|
@@ -43,25 +51,27 @@ Base functionality used throughout XYO TypeScript/JavaScript libraries that acce
|
|
|
43
51
|
|
|
44
52
|
***
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
Provides a typed wrapper around common MongoDB collection operations.
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
## Type Parameters
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
| Type Parameter |
|
|
59
|
+
| ------ |
|
|
60
|
+
| `T` *extends* `Document` |
|
|
51
61
|
|
|
52
62
|
## Constructors
|
|
53
63
|
|
|
54
64
|
### Constructor
|
|
55
65
|
|
|
56
66
|
```ts
|
|
57
|
-
new BaseMongoSdk<T>(config): BaseMongoSdk<T>;
|
|
67
|
+
new BaseMongoSdk<T>(config: BaseMongoSdkConfig): BaseMongoSdk<T>;
|
|
58
68
|
```
|
|
59
69
|
|
|
60
70
|
### Parameters
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[`BaseMongoSdkConfig`](#../type-aliases/BaseMongoSdkConfig)
|
|
72
|
+
| Parameter | Type |
|
|
73
|
+
| ------ | ------ |
|
|
74
|
+
| `config` | [`BaseMongoSdkConfig`](#../type-aliases/BaseMongoSdkConfig) |
|
|
65
75
|
|
|
66
76
|
### Returns
|
|
67
77
|
|
|
@@ -69,11 +79,9 @@ new BaseMongoSdk<T>(config): BaseMongoSdk<T>;
|
|
|
69
79
|
|
|
70
80
|
## Properties
|
|
71
81
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
config: BaseMongoSdkConfig;
|
|
76
|
-
```
|
|
82
|
+
| Property | Type | Description |
|
|
83
|
+
| ------ | ------ | ------ |
|
|
84
|
+
| <a id="config"></a> `config` | [`BaseMongoSdkConfig`](#../type-aliases/BaseMongoSdkConfig) | The MongoDB SDK configuration for this instance. |
|
|
77
85
|
|
|
78
86
|
## Accessors
|
|
79
87
|
|
|
@@ -85,6 +93,8 @@ config: BaseMongoSdkConfig;
|
|
|
85
93
|
get uri(): string;
|
|
86
94
|
```
|
|
87
95
|
|
|
96
|
+
Returns the MongoDB connection URI, either from the config or constructed from individual credential fields.
|
|
97
|
+
|
|
88
98
|
#### Returns
|
|
89
99
|
|
|
90
100
|
`string`
|
|
@@ -94,14 +104,16 @@ get uri(): string;
|
|
|
94
104
|
### deleteMany()
|
|
95
105
|
|
|
96
106
|
```ts
|
|
97
|
-
deleteMany(filter): Promise<DeleteResult>;
|
|
107
|
+
deleteMany(filter: Filter<T>): Promise<DeleteResult>;
|
|
98
108
|
```
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
Deletes all documents matching the filter.
|
|
101
111
|
|
|
102
|
-
|
|
112
|
+
### Parameters
|
|
103
113
|
|
|
104
|
-
|
|
114
|
+
| Parameter | Type | Description |
|
|
115
|
+
| ------ | ------ | ------ |
|
|
116
|
+
| `filter` | `Filter`\<`T`\> | The query filter to match documents for deletion |
|
|
105
117
|
|
|
106
118
|
### Returns
|
|
107
119
|
|
|
@@ -112,14 +124,16 @@ deleteMany(filter): Promise<DeleteResult>;
|
|
|
112
124
|
### deleteOne()
|
|
113
125
|
|
|
114
126
|
```ts
|
|
115
|
-
deleteOne(filter): Promise<DeleteResult>;
|
|
127
|
+
deleteOne(filter: Filter<T>): Promise<DeleteResult>;
|
|
116
128
|
```
|
|
117
129
|
|
|
118
|
-
|
|
130
|
+
Deletes the first document matching the filter.
|
|
119
131
|
|
|
120
|
-
|
|
132
|
+
### Parameters
|
|
121
133
|
|
|
122
|
-
|
|
134
|
+
| Parameter | Type | Description |
|
|
135
|
+
| ------ | ------ | ------ |
|
|
136
|
+
| `filter` | `Filter`\<`T`\> | The query filter to match a document for deletion |
|
|
123
137
|
|
|
124
138
|
### Returns
|
|
125
139
|
|
|
@@ -130,14 +144,16 @@ deleteOne(filter): Promise<DeleteResult>;
|
|
|
130
144
|
### find()
|
|
131
145
|
|
|
132
146
|
```ts
|
|
133
|
-
find(filter): Promise<FindCursor<WithId<T>>>;
|
|
147
|
+
find(filter: Filter<T>): Promise<FindCursor<WithId<T>>>;
|
|
134
148
|
```
|
|
135
149
|
|
|
136
|
-
|
|
150
|
+
Finds all documents matching the filter and returns a cursor.
|
|
137
151
|
|
|
138
|
-
|
|
152
|
+
### Parameters
|
|
139
153
|
|
|
140
|
-
|
|
154
|
+
| Parameter | Type | Description |
|
|
155
|
+
| ------ | ------ | ------ |
|
|
156
|
+
| `filter` | `Filter`\<`T`\> | The query filter |
|
|
141
157
|
|
|
142
158
|
### Returns
|
|
143
159
|
|
|
@@ -148,36 +164,39 @@ find(filter): Promise<FindCursor<WithId<T>>>;
|
|
|
148
164
|
### findOne()
|
|
149
165
|
|
|
150
166
|
```ts
|
|
151
|
-
findOne(filter): Promise<WithId<T> | null>;
|
|
167
|
+
findOne(filter: Filter<T>): Promise<WithId<T> | null>;
|
|
152
168
|
```
|
|
153
169
|
|
|
154
|
-
|
|
170
|
+
Finds a single document matching the filter.
|
|
155
171
|
|
|
156
|
-
|
|
172
|
+
### Parameters
|
|
157
173
|
|
|
158
|
-
|
|
174
|
+
| Parameter | Type | Description |
|
|
175
|
+
| ------ | ------ | ------ |
|
|
176
|
+
| `filter` | `Filter`\<`T`\> | The query filter |
|
|
159
177
|
|
|
160
178
|
### Returns
|
|
161
179
|
|
|
162
180
|
`Promise`\<`WithId`\<`T`\> \| `null`\>
|
|
163
181
|
|
|
182
|
+
The matched document, or `null` if not found
|
|
183
|
+
|
|
164
184
|
***
|
|
165
185
|
|
|
166
186
|
### insertMany()
|
|
167
187
|
|
|
168
188
|
```ts
|
|
169
|
-
insertMany(items, options
|
|
189
|
+
insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions): Promise<InsertManyResult<T>>;
|
|
170
190
|
```
|
|
171
191
|
|
|
172
|
-
|
|
192
|
+
Inserts multiple documents into the collection.
|
|
173
193
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
`OptionalUnlessRequiredId`\<`T`\>[]
|
|
177
|
-
|
|
178
|
-
#### options?
|
|
194
|
+
### Parameters
|
|
179
195
|
|
|
180
|
-
|
|
196
|
+
| Parameter | Type | Description |
|
|
197
|
+
| ------ | ------ | ------ |
|
|
198
|
+
| `items` | `OptionalUnlessRequiredId`\<`T`\>[] | The documents to insert |
|
|
199
|
+
| `options?` | `BulkWriteOptions` | Optional bulk write options |
|
|
181
200
|
|
|
182
201
|
### Returns
|
|
183
202
|
|
|
@@ -188,18 +207,17 @@ insertMany(items, options?): Promise<InsertManyResult<T>>;
|
|
|
188
207
|
### insertOne()
|
|
189
208
|
|
|
190
209
|
```ts
|
|
191
|
-
insertOne(item
|
|
210
|
+
insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions): Promise<InsertOneResult<T>>;
|
|
192
211
|
```
|
|
193
212
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
#### item
|
|
213
|
+
Inserts a single document into the collection.
|
|
197
214
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#### options?
|
|
215
|
+
### Parameters
|
|
201
216
|
|
|
202
|
-
|
|
217
|
+
| Parameter | Type | Description |
|
|
218
|
+
| ------ | ------ | ------ |
|
|
219
|
+
| `item` | `OptionalUnlessRequiredId`\<`T`\> | The document to insert |
|
|
220
|
+
| `options?` | `InsertOneOptions` | Optional insert options |
|
|
203
221
|
|
|
204
222
|
### Returns
|
|
205
223
|
|
|
@@ -211,24 +229,20 @@ insertOne(item, options?): Promise<InsertOneResult<T>>;
|
|
|
211
229
|
|
|
212
230
|
```ts
|
|
213
231
|
replaceOne(
|
|
214
|
-
filter
|
|
215
|
-
item
|
|
216
|
-
options
|
|
232
|
+
filter: Filter<T>,
|
|
233
|
+
item: OptionalUnlessRequiredId<T>,
|
|
234
|
+
options?: ReplaceOptions): Promise<UpdateResult<T>>;
|
|
217
235
|
```
|
|
218
236
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
#### filter
|
|
222
|
-
|
|
223
|
-
`Filter`\<`T`\>
|
|
237
|
+
Replaces a single document matching the filter.
|
|
224
238
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
`OptionalUnlessRequiredId`\<`T`\>
|
|
228
|
-
|
|
229
|
-
#### options?
|
|
239
|
+
### Parameters
|
|
230
240
|
|
|
231
|
-
|
|
241
|
+
| Parameter | Type | Description |
|
|
242
|
+
| ------ | ------ | ------ |
|
|
243
|
+
| `filter` | `Filter`\<`T`\> | The query filter to match the document |
|
|
244
|
+
| `item` | `OptionalUnlessRequiredId`\<`T`\> | The replacement document |
|
|
245
|
+
| `options?` | `ReplaceOptions` | Optional replace options |
|
|
232
246
|
|
|
233
247
|
### Returns
|
|
234
248
|
|
|
@@ -239,18 +253,17 @@ options?): Promise<UpdateResult<T>>;
|
|
|
239
253
|
### updateOne()
|
|
240
254
|
|
|
241
255
|
```ts
|
|
242
|
-
updateOne(filter
|
|
256
|
+
updateOne(filter: Filter<T>, fields: UpdateFilter<T>): Promise<UpdateResult<T>>;
|
|
243
257
|
```
|
|
244
258
|
|
|
245
|
-
|
|
259
|
+
Updates a single document matching the filter without upserting.
|
|
246
260
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
`Filter`\<`T`\>
|
|
250
|
-
|
|
251
|
-
#### fields
|
|
261
|
+
### Parameters
|
|
252
262
|
|
|
253
|
-
|
|
263
|
+
| Parameter | Type | Description |
|
|
264
|
+
| ------ | ------ | ------ |
|
|
265
|
+
| `filter` | `Filter`\<`T`\> | The query filter to match the document |
|
|
266
|
+
| `fields` | `UpdateFilter`\<`T`\> | The update operations to apply |
|
|
254
267
|
|
|
255
268
|
### Returns
|
|
256
269
|
|
|
@@ -261,18 +274,17 @@ updateOne(filter, fields): Promise<UpdateResult<T>>;
|
|
|
261
274
|
### upsertOne()
|
|
262
275
|
|
|
263
276
|
```ts
|
|
264
|
-
upsertOne(filter
|
|
277
|
+
upsertOne(filter: Filter<T>, fields: UpdateFilter<T>): Promise<UpdateResult<T>>;
|
|
265
278
|
```
|
|
266
279
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
#### filter
|
|
280
|
+
Updates a single document matching the filter, inserting it if it does not exist.
|
|
270
281
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
#### fields
|
|
282
|
+
### Parameters
|
|
274
283
|
|
|
275
|
-
|
|
284
|
+
| Parameter | Type | Description |
|
|
285
|
+
| ------ | ------ | ------ |
|
|
286
|
+
| `filter` | `Filter`\<`T`\> | The query filter to match the document |
|
|
287
|
+
| `fields` | `UpdateFilter`\<`T`\> | The update operations to apply |
|
|
276
288
|
|
|
277
289
|
### Returns
|
|
278
290
|
|
|
@@ -283,79 +295,83 @@ upsertOne(filter, fields): Promise<UpdateResult<T>>;
|
|
|
283
295
|
### useCollection()
|
|
284
296
|
|
|
285
297
|
```ts
|
|
286
|
-
useCollection<R>(func): Promise<R>;
|
|
298
|
+
useCollection<R>(func: (collection: Collection<T>) => R | Promise<R>): Promise<R>;
|
|
287
299
|
```
|
|
288
300
|
|
|
289
|
-
|
|
301
|
+
Executes a callback with access to the configured MongoDB collection.
|
|
290
302
|
|
|
291
|
-
|
|
303
|
+
### Type Parameters
|
|
292
304
|
|
|
293
|
-
|
|
305
|
+
| Type Parameter |
|
|
306
|
+
| ------ |
|
|
307
|
+
| `R` |
|
|
294
308
|
|
|
295
309
|
### Parameters
|
|
296
310
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
(`collection`) => `R` \| `Promise`\<`R`\>
|
|
311
|
+
| Parameter | Type | Description |
|
|
312
|
+
| ------ | ------ | ------ |
|
|
313
|
+
| `func` | (`collection`: `Collection`\<`T`\>) => `R` \| `Promise`\<`R`\> | A callback receiving the typed collection |
|
|
300
314
|
|
|
301
315
|
### Returns
|
|
302
316
|
|
|
303
317
|
`Promise`\<`R`\>
|
|
304
318
|
|
|
319
|
+
The result of the callback
|
|
320
|
+
|
|
305
321
|
***
|
|
306
322
|
|
|
307
323
|
### useMongo()
|
|
308
324
|
|
|
309
325
|
```ts
|
|
310
|
-
useMongo<R>(func): Promise<R>;
|
|
326
|
+
useMongo<R>(func: (client: MongoClient) => R | Promise<R>): Promise<R>;
|
|
311
327
|
```
|
|
312
328
|
|
|
313
|
-
|
|
329
|
+
Executes a callback with a connected MongoClient, handling connection and disconnection.
|
|
314
330
|
|
|
315
|
-
|
|
331
|
+
### Type Parameters
|
|
316
332
|
|
|
317
|
-
|
|
333
|
+
| Type Parameter |
|
|
334
|
+
| ------ |
|
|
335
|
+
| `R` |
|
|
318
336
|
|
|
319
337
|
### Parameters
|
|
320
338
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
(`client`) => `R` \| `Promise`\<`R`\>
|
|
339
|
+
| Parameter | Type | Description |
|
|
340
|
+
| ------ | ------ | ------ |
|
|
341
|
+
| `func` | (`client`: `MongoClient`) => `R` \| `Promise`\<`R`\> | A callback receiving the connected MongoClient |
|
|
324
342
|
|
|
325
343
|
### Returns
|
|
326
344
|
|
|
327
345
|
`Promise`\<`R`\>
|
|
328
346
|
|
|
347
|
+
The result of the callback
|
|
348
|
+
|
|
329
349
|
### <a id="MongoClientWrapper"></a>MongoClientWrapper
|
|
330
350
|
|
|
331
351
|
[**@xylabs/mongo**](#../README)
|
|
332
352
|
|
|
333
353
|
***
|
|
334
354
|
|
|
355
|
+
Manages a shared pool of MongoClient instances, reusing connections by URI.
|
|
356
|
+
|
|
335
357
|
## Constructors
|
|
336
358
|
|
|
337
359
|
### Constructor
|
|
338
360
|
|
|
339
361
|
```ts
|
|
340
362
|
new MongoClientWrapper(
|
|
341
|
-
uri,
|
|
342
|
-
maxPoolSize
|
|
343
|
-
closeDelay
|
|
363
|
+
uri: string,
|
|
364
|
+
maxPoolSize?: number,
|
|
365
|
+
closeDelay?: number): MongoClientWrapper;
|
|
344
366
|
```
|
|
345
367
|
|
|
346
368
|
### Parameters
|
|
347
369
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
`string`
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
`number`
|
|
355
|
-
|
|
356
|
-
#### closeDelay?
|
|
357
|
-
|
|
358
|
-
`number`
|
|
370
|
+
| Parameter | Type |
|
|
371
|
+
| ------ | ------ |
|
|
372
|
+
| `uri` | `string` |
|
|
373
|
+
| `maxPoolSize?` | `number` |
|
|
374
|
+
| `closeDelay?` | `number` |
|
|
359
375
|
|
|
360
376
|
### Returns
|
|
361
377
|
|
|
@@ -363,11 +379,9 @@ new MongoClientWrapper(
|
|
|
363
379
|
|
|
364
380
|
## Properties
|
|
365
381
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
readonly static clients: Map<string, MongoClientWrapper>;
|
|
370
|
-
```
|
|
382
|
+
| Property | Modifier | Type | Description |
|
|
383
|
+
| ------ | ------ | ------ | ------ |
|
|
384
|
+
| <a id="clients"></a> `clients` | `readonly` | `Map`\<`string`, `MongoClientWrapper`\> | Global cache of wrapper instances keyed by connection URI. |
|
|
371
385
|
|
|
372
386
|
## Methods
|
|
373
387
|
|
|
@@ -375,29 +389,27 @@ readonly static clients: Map<string, MongoClientWrapper>;
|
|
|
375
389
|
|
|
376
390
|
```ts
|
|
377
391
|
static get(
|
|
378
|
-
uri,
|
|
379
|
-
poolSize
|
|
380
|
-
closeDelay
|
|
392
|
+
uri: string,
|
|
393
|
+
poolSize?: number,
|
|
394
|
+
closeDelay?: number): MongoClientWrapper;
|
|
381
395
|
```
|
|
382
396
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
#### uri
|
|
386
|
-
|
|
387
|
-
`string`
|
|
388
|
-
|
|
389
|
-
#### poolSize?
|
|
397
|
+
Gets or creates a cached MongoClientWrapper for the given URI.
|
|
390
398
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
#### closeDelay?
|
|
399
|
+
### Parameters
|
|
394
400
|
|
|
395
|
-
|
|
401
|
+
| Parameter | Type | Description |
|
|
402
|
+
| ------ | ------ | ------ |
|
|
403
|
+
| `uri` | `string` | The MongoDB connection URI |
|
|
404
|
+
| `poolSize?` | `number` | Maximum connection pool size |
|
|
405
|
+
| `closeDelay?` | `number` | Delay in milliseconds before closing idle connections |
|
|
396
406
|
|
|
397
407
|
### Returns
|
|
398
408
|
|
|
399
409
|
`MongoClientWrapper`
|
|
400
410
|
|
|
411
|
+
A cached or newly created wrapper instance
|
|
412
|
+
|
|
401
413
|
***
|
|
402
414
|
|
|
403
415
|
### connect()
|
|
@@ -406,6 +418,8 @@ static get(
|
|
|
406
418
|
connect(): Promise<MongoClient>;
|
|
407
419
|
```
|
|
408
420
|
|
|
421
|
+
Connects to MongoDB and returns the underlying MongoClient.
|
|
422
|
+
|
|
409
423
|
### Returns
|
|
410
424
|
|
|
411
425
|
`Promise`\<`MongoClient`\>
|
|
@@ -418,6 +432,8 @@ connect(): Promise<MongoClient>;
|
|
|
418
432
|
disconnect(): Promise<number>;
|
|
419
433
|
```
|
|
420
434
|
|
|
435
|
+
Disconnects from MongoDB.
|
|
436
|
+
|
|
421
437
|
### Returns
|
|
422
438
|
|
|
423
439
|
`Promise`\<`number`\>
|
|
@@ -430,6 +446,8 @@ disconnect(): Promise<number>;
|
|
|
430
446
|
initiateClose(): Promise<void>;
|
|
431
447
|
```
|
|
432
448
|
|
|
449
|
+
Initiates a graceful close of the connection.
|
|
450
|
+
|
|
433
451
|
### Returns
|
|
434
452
|
|
|
435
453
|
`Promise`\<`void`\>
|
|
@@ -442,45 +460,17 @@ initiateClose(): Promise<void>;
|
|
|
442
460
|
|
|
443
461
|
***
|
|
444
462
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
### dbConnectionString?
|
|
448
|
-
|
|
449
|
-
```ts
|
|
450
|
-
optional dbConnectionString: string;
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
***
|
|
454
|
-
|
|
455
|
-
### dbDomain?
|
|
456
|
-
|
|
457
|
-
```ts
|
|
458
|
-
optional dbDomain: string;
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
***
|
|
462
|
-
|
|
463
|
-
### dbName?
|
|
464
|
-
|
|
465
|
-
```ts
|
|
466
|
-
optional dbName: string;
|
|
467
|
-
```
|
|
463
|
+
Private configuration options for the Mongo SDK containing connection credentials.
|
|
468
464
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
### dbPassword?
|
|
472
|
-
|
|
473
|
-
```ts
|
|
474
|
-
optional dbPassword: string;
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
***
|
|
478
|
-
|
|
479
|
-
### dbUserName?
|
|
465
|
+
## Properties
|
|
480
466
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
467
|
+
| Property | Type | Description |
|
|
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. |
|
|
484
474
|
|
|
485
475
|
### <a id="BaseMongoSdkPublicConfig"></a>BaseMongoSdkPublicConfig
|
|
486
476
|
|
|
@@ -488,29 +478,15 @@ optional dbUserName: string;
|
|
|
488
478
|
|
|
489
479
|
***
|
|
490
480
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
### closeDelay?
|
|
494
|
-
|
|
495
|
-
```ts
|
|
496
|
-
optional closeDelay: number;
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
***
|
|
500
|
-
|
|
501
|
-
### collection
|
|
502
|
-
|
|
503
|
-
```ts
|
|
504
|
-
collection: string;
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
***
|
|
481
|
+
Public configuration options for the Mongo SDK, safe to expose to clients.
|
|
508
482
|
|
|
509
|
-
|
|
483
|
+
## Properties
|
|
510
484
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
485
|
+
| Property | Type | Description |
|
|
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. |
|
|
514
490
|
|
|
515
491
|
### type-aliases
|
|
516
492
|
|
|
@@ -524,6 +500,8 @@ optional maxPoolSize: number;
|
|
|
524
500
|
type BaseMongoSdkConfig = BaseMongoSdkPublicConfig & BaseMongoSdkPrivateConfig;
|
|
525
501
|
```
|
|
526
502
|
|
|
503
|
+
Combined public and private MongoDB SDK configuration.
|
|
504
|
+
|
|
527
505
|
|
|
528
506
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
529
507
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/mongo",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.86",
|
|
4
4
|
"description": "Base functionality used throughout XYO TypeScript/JavaScript libraries that access Mongo DB",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mongo",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"!**/*.test.*"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@xylabs/assert": "~5.0.
|
|
49
|
+
"@xylabs/assert": "~5.0.86"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@xylabs/tsconfig": "~7.4.
|
|
52
|
+
"@xylabs/tsconfig": "~7.4.16",
|
|
53
53
|
"mongodb": "^7.1.0",
|
|
54
54
|
"typescript": "~5.9.3",
|
|
55
55
|
"vitest": "~4.0.18"
|