@lossless.org/client 1.6.0 → 1.8.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/nosqldb/classes.atomicdelete.d.ts +1 -0
- package/dist_ts/nosqldb/classes.atomicdelete.js +10 -7
- package/dist_ts/nosqldb/classes.atomicfindoneandupdate.d.ts +2 -0
- package/dist_ts/nosqldb/classes.atomicfindoneandupdate.js +9 -5
- package/dist_ts/nosqldb/classes.atomicupdate.d.ts +2 -0
- package/dist_ts/nosqldb/classes.atomicupdate.js +13 -8
- package/dist_ts/nosqldb/classes.collection.d.ts +13 -4
- package/dist_ts/nosqldb/classes.collection.js +57 -64
- package/dist_ts/nosqldb/classes.db.d.ts +1 -1
- package/dist_ts/nosqldb/classes.doc.d.ts +60 -3
- package/dist_ts/nosqldb/classes.doc.js +68 -26
- package/dist_ts/nosqldb/classes.exactpersistence.d.ts +36 -7
- package/dist_ts/nosqldb/classes.exactpersistence.js +92 -81
- package/dist_ts/nosqldb/classes.operationdeadline.d.ts +61 -0
- package/dist_ts/nosqldb/classes.operationdeadline.js +149 -0
- package/dist_ts/nosqldb/classes.persistence.d.ts +16 -1
- package/dist_ts/nosqldb/classes.persistence.js +20 -1
- package/dist_ts/nosqldb/classes.session.d.ts +73 -2
- package/dist_ts/nosqldb/classes.session.js +164 -38
- package/dist_ts/objectstorage/classes.bucket.d.ts +61 -3
- package/dist_ts/objectstorage/classes.bucket.js +243 -184
- package/dist_ts/objectstorage/classes.directory.js +17 -28
- package/dist_ts/objectstorage/classes.smartbucket.d.ts +13 -6
- package/dist_ts/objectstorage/classes.smartbucket.js +18 -12
- package/dist_ts/objectstorage/classes.watcher.js +1 -2
- package/dist_ts/objectstorage/interfaces.d.ts +8 -0
- package/dist_ts/objectstorage/internal.bucketrequests.d.ts +14 -0
- package/dist_ts/objectstorage/internal.bucketrequests.js +53 -0
- package/dist_ts/objectstorage/internal.exactupload.capability.d.ts +12 -0
- package/dist_ts/objectstorage/internal.exactupload.capability.js +46 -17
- package/package.json +3 -3
- package/readme.md +13 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/nosqldb/classes.atomicdelete.ts +10 -6
- package/ts/nosqldb/classes.atomicfindoneandupdate.ts +10 -4
- package/ts/nosqldb/classes.atomicupdate.ts +14 -7
- package/ts/nosqldb/classes.collection.ts +82 -73
- package/ts/nosqldb/classes.db.ts +1 -1
- package/ts/nosqldb/classes.doc.ts +162 -33
- package/ts/nosqldb/classes.exactpersistence.ts +131 -93
- package/ts/nosqldb/classes.operationdeadline.ts +179 -0
- package/ts/nosqldb/classes.persistence.ts +36 -1
- package/ts/nosqldb/classes.session.ts +221 -39
- package/ts/objectstorage/classes.bucket.ts +350 -218
- package/ts/objectstorage/classes.directory.ts +18 -27
- package/ts/objectstorage/classes.smartbucket.ts +21 -11
- package/ts/objectstorage/classes.watcher.ts +0 -1
- package/ts/objectstorage/interfaces.ts +9 -0
- package/ts/objectstorage/internal.bucketrequests.ts +70 -0
- package/ts/objectstorage/internal.exactupload.capability.ts +105 -24
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
normalizeOrdinaryPersistenceError,
|
|
29
29
|
} from './classes.persistence.js';
|
|
30
30
|
import { notifyCollectionReconnect } from './classes.collectionlifecycle.js';
|
|
31
|
+
import type { SmartdataOperationDeadline } from './classes.operationdeadline.js';
|
|
31
32
|
import {
|
|
32
33
|
leaseOrdinarySmartdataSession,
|
|
33
34
|
runWithOrdinarySmartdataSession,
|
|
@@ -1803,18 +1804,21 @@ export class SmartdataCollection<T> {
|
|
|
1803
1804
|
|
|
1804
1805
|
private runWithOrdinarySession<TResult>(
|
|
1805
1806
|
sessionArg: TSmartdataOrdinarySession | undefined,
|
|
1806
|
-
|
|
1807
|
+
optionsArg: { ordinaryWrite: boolean; timeoutMS?: number; signal?: AbortSignal },
|
|
1807
1808
|
operationArg: (
|
|
1808
1809
|
rawSessionArg: plugins.mongodb.ClientSession | undefined,
|
|
1810
|
+
deadlineArg: SmartdataOperationDeadline,
|
|
1809
1811
|
) => Promise<TResult>,
|
|
1810
1812
|
): Promise<TResult> {
|
|
1811
1813
|
return runWithOrdinarySmartdataSession(
|
|
1812
1814
|
sessionArg,
|
|
1813
1815
|
this.smartdataDb,
|
|
1814
1816
|
{
|
|
1815
|
-
ordinaryWrite:
|
|
1817
|
+
ordinaryWrite: optionsArg.ordinaryWrite,
|
|
1816
1818
|
prepared: this.isInitializedForCurrentDatabase(),
|
|
1817
1819
|
collectionName: this.collectionName,
|
|
1820
|
+
timeoutMS: optionsArg.timeoutMS,
|
|
1821
|
+
signal: optionsArg.signal,
|
|
1818
1822
|
},
|
|
1819
1823
|
operationArg,
|
|
1820
1824
|
);
|
|
@@ -2141,9 +2145,13 @@ export class SmartdataCollection<T> {
|
|
|
2141
2145
|
}
|
|
2142
2146
|
|
|
2143
2147
|
/**
|
|
2144
|
-
*
|
|
2148
|
+
* Creates the single-field unique indexes the collection has not built yet,
|
|
2149
|
+
* each within the time the calling operation's deadline has left.
|
|
2145
2150
|
*/
|
|
2146
|
-
public async markUniqueIndexes(
|
|
2151
|
+
public async markUniqueIndexes(
|
|
2152
|
+
keyArrayArg: string[] = [],
|
|
2153
|
+
deadlineArg?: SmartdataOperationDeadline,
|
|
2154
|
+
) {
|
|
2147
2155
|
for (const key of keyArrayArg) {
|
|
2148
2156
|
if (key === this.modelSchema?.identityAsDocumentId) {
|
|
2149
2157
|
// The primary key already enforces this identity; building a second
|
|
@@ -2157,6 +2165,7 @@ export class SmartdataCollection<T> {
|
|
|
2157
2165
|
// A bound model may back its identity with a differently named
|
|
2158
2166
|
// index; creating `<field>_1` would duplicate that key.
|
|
2159
2167
|
name: getIdentityIndexName(this.modelSchema, key) ?? `${key}_1`,
|
|
2168
|
+
...deadlineArg?.commandOptions(),
|
|
2160
2169
|
});
|
|
2161
2170
|
this.uniqueIndexes.push(key);
|
|
2162
2171
|
} catch (err: any) {
|
|
@@ -2178,9 +2187,13 @@ export class SmartdataCollection<T> {
|
|
|
2178
2187
|
}
|
|
2179
2188
|
|
|
2180
2189
|
/**
|
|
2181
|
-
*
|
|
2190
|
+
* Creates the regular indexes the collection has not built yet, each within
|
|
2191
|
+
* the time the calling operation's deadline has left.
|
|
2182
2192
|
*/
|
|
2183
|
-
public async createRegularIndexes(
|
|
2193
|
+
public async createRegularIndexes(
|
|
2194
|
+
indexesArg: Array<{field: string, options: IIndexOptions}> = [],
|
|
2195
|
+
deadlineArg?: SmartdataOperationDeadline,
|
|
2196
|
+
) {
|
|
2184
2197
|
for (const indexDef of indexesArg) {
|
|
2185
2198
|
// Check if we've already created this index
|
|
2186
2199
|
const indexKey = indexDef.field;
|
|
@@ -2188,7 +2201,7 @@ export class SmartdataCollection<T> {
|
|
|
2188
2201
|
try {
|
|
2189
2202
|
await this.mongoDbCollection.createIndex(
|
|
2190
2203
|
{ [indexDef.field]: 1 }, // Simple single-field index
|
|
2191
|
-
indexDef.options
|
|
2204
|
+
{ ...indexDef.options, ...deadlineArg?.commandOptions() },
|
|
2192
2205
|
);
|
|
2193
2206
|
this.regularIndexes.push(indexDef);
|
|
2194
2207
|
} catch (err: any) {
|
|
@@ -2260,18 +2273,20 @@ export class SmartdataCollection<T> {
|
|
|
2260
2273
|
opts?: {
|
|
2261
2274
|
projection?: plugins.mongodb.Document;
|
|
2262
2275
|
maxTimeMS?: number;
|
|
2276
|
+
timeoutMS?: number;
|
|
2263
2277
|
session?: TSmartdataOrdinarySession;
|
|
2264
2278
|
},
|
|
2265
2279
|
): Promise<any> {
|
|
2266
2280
|
return this.runWithOrdinarySession(
|
|
2267
2281
|
opts?.session,
|
|
2268
|
-
false,
|
|
2269
|
-
async (rawSessionArg) => {
|
|
2270
|
-
await this.init();
|
|
2282
|
+
{ ordinaryWrite: false, timeoutMS: opts?.timeoutMS },
|
|
2283
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2284
|
+
await deadlineArg.join(this.init());
|
|
2271
2285
|
return this.mongoDbCollection.findOne(filterObject, {
|
|
2272
2286
|
projection: opts?.projection,
|
|
2273
2287
|
maxTimeMS: opts?.maxTimeMS,
|
|
2274
2288
|
session: rawSessionArg,
|
|
2289
|
+
...deadlineArg.commandOptions(),
|
|
2275
2290
|
});
|
|
2276
2291
|
},
|
|
2277
2292
|
);
|
|
@@ -2308,32 +2323,25 @@ export class SmartdataCollection<T> {
|
|
|
2308
2323
|
*/
|
|
2309
2324
|
public async findAll(
|
|
2310
2325
|
filterObject: any,
|
|
2311
|
-
opts?: { session?: TSmartdataOrdinarySession }
|
|
2326
|
+
opts?: { session?: TSmartdataOrdinarySession; timeoutMS?: number }
|
|
2312
2327
|
): Promise<any[]> {
|
|
2313
2328
|
return this.runWithOrdinarySession(
|
|
2314
2329
|
opts?.session,
|
|
2315
|
-
false,
|
|
2316
|
-
async (rawSessionArg) => {
|
|
2317
|
-
await this.init();
|
|
2330
|
+
{ ordinaryWrite: false, timeoutMS: opts?.timeoutMS },
|
|
2331
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2332
|
+
await deadlineArg.join(this.init());
|
|
2318
2333
|
const cursor = this.mongoDbCollection.find(filterObject, {
|
|
2319
2334
|
session: rawSessionArg,
|
|
2335
|
+
...deadlineArg.cursorOptions(),
|
|
2320
2336
|
});
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
try {
|
|
2330
|
-
await cursor.close();
|
|
2331
|
-
} catch (closeError) {
|
|
2332
|
-
if (!operationFailed) {
|
|
2333
|
-
throw closeError;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
+
// An enclosing transaction's signal reaches this cursor, and the
|
|
2338
|
+
// driver's abort listener does not await its close, so every close
|
|
2339
|
+
// joins one native cleanup before the session lease is released.
|
|
2340
|
+
const result: any[] = await runCursorOperation(
|
|
2341
|
+
cursor,
|
|
2342
|
+
(cursorArg) => cursorArg.toArray(),
|
|
2343
|
+
deadlineArg.signal,
|
|
2344
|
+
);
|
|
2337
2345
|
|
|
2338
2346
|
// In-memory check for duplicate _id values (should never happen)
|
|
2339
2347
|
if (result.length > 0) {
|
|
@@ -2453,27 +2461,28 @@ export class SmartdataCollection<T> {
|
|
|
2453
2461
|
|
|
2454
2462
|
public async insert(
|
|
2455
2463
|
dbDocArg: T & SmartDataDbDoc<T, unknown>,
|
|
2456
|
-
opts?: { session?: TSmartdataOrdinarySession }
|
|
2464
|
+
opts?: { session?: TSmartdataOrdinarySession; timeoutMS?: number }
|
|
2457
2465
|
): Promise<any> {
|
|
2458
2466
|
const preparedObject = this.preparesStoredDocuments
|
|
2459
2467
|
? this.prepareOrdinaryInsert(await dbDocArg.createSavableObject()) : undefined;
|
|
2460
2468
|
return this.runWithOrdinarySession(
|
|
2461
2469
|
opts?.session,
|
|
2462
|
-
true,
|
|
2463
|
-
async (rawSessionArg) => {
|
|
2464
|
-
await this.init();
|
|
2470
|
+
{ ordinaryWrite: true, timeoutMS: opts?.timeoutMS },
|
|
2471
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2472
|
+
await deadlineArg.join(this.init());
|
|
2465
2473
|
await this.checkDoc(dbDocArg);
|
|
2466
|
-
await this.markUniqueIndexes(dbDocArg.uniqueIndexes);
|
|
2474
|
+
await this.markUniqueIndexes(dbDocArg.uniqueIndexes, deadlineArg);
|
|
2467
2475
|
|
|
2468
2476
|
// Create regular indexes if available
|
|
2469
2477
|
if (dbDocArg.regularIndexes && dbDocArg.regularIndexes.length > 0) {
|
|
2470
|
-
await this.createRegularIndexes(dbDocArg.regularIndexes);
|
|
2478
|
+
await this.createRegularIndexes(dbDocArg.regularIndexes, deadlineArg);
|
|
2471
2479
|
}
|
|
2472
2480
|
|
|
2473
2481
|
const saveableObject = preparedObject ?? await dbDocArg.createSavableObject();
|
|
2474
2482
|
try {
|
|
2475
2483
|
return await this.mongoDbCollection.insertOne(saveableObject, {
|
|
2476
2484
|
session: rawSessionArg,
|
|
2485
|
+
...deadlineArg.commandOptions(),
|
|
2477
2486
|
});
|
|
2478
2487
|
} catch (err: any) {
|
|
2479
2488
|
return normalizeOrdinaryPersistenceError(
|
|
@@ -2497,35 +2506,32 @@ export class SmartdataCollection<T> {
|
|
|
2497
2506
|
limitArg: number,
|
|
2498
2507
|
opts?: { session?: TSmartdataOrdinarySession; maxTimeMS?: number; timeoutMS?: number; signal?: AbortSignal }
|
|
2499
2508
|
): Promise<plugins.mongodb.Document[]> {
|
|
2500
|
-
opts?.signal?.throwIfAborted();
|
|
2501
2509
|
return this.runWithOrdinarySession(
|
|
2502
2510
|
opts?.session,
|
|
2503
|
-
false,
|
|
2504
|
-
async (rawSessionArg) => {
|
|
2505
|
-
await this.init();
|
|
2511
|
+
{ ordinaryWrite: false, timeoutMS: opts?.timeoutMS, signal: opts?.signal },
|
|
2512
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2513
|
+
await deadlineArg.join(this.init());
|
|
2506
2514
|
const pipeline: plugins.mongodb.Document[] = [];
|
|
2507
2515
|
if (matchArg && Object.keys(matchArg).length > 0) {
|
|
2508
2516
|
pipeline.push({ $match: matchArg });
|
|
2509
2517
|
}
|
|
2510
2518
|
pipeline.push({ $group: groupArg });
|
|
2511
2519
|
pipeline.push({ $limit: limitArg });
|
|
2512
|
-
opts?.signal?.throwIfAborted();
|
|
2513
2520
|
const cursor = this.mongoDbCollection.aggregate(pipeline, {
|
|
2514
2521
|
session: rawSessionArg,
|
|
2515
|
-
...(
|
|
2516
|
-
signal: opts?.signal,
|
|
2522
|
+
...deadlineArg.cursorOptions(),
|
|
2517
2523
|
...(opts?.maxTimeMS !== undefined
|
|
2518
2524
|
? { maxTimeMS: opts.maxTimeMS }
|
|
2519
2525
|
: {}),
|
|
2520
2526
|
});
|
|
2521
|
-
return runCursorOperation(cursor, (cursorArg) => cursorArg.toArray(),
|
|
2527
|
+
return runCursorOperation(cursor, (cursorArg) => cursorArg.toArray(), deadlineArg.signal);
|
|
2522
2528
|
},
|
|
2523
2529
|
);
|
|
2524
2530
|
}
|
|
2525
2531
|
|
|
2526
2532
|
public async insertMany(
|
|
2527
2533
|
dbDocsArg: Array<T & SmartDataDbDoc<T, unknown>>,
|
|
2528
|
-
opts?: { session?: TSmartdataOrdinarySession; ordered?: boolean }
|
|
2534
|
+
opts?: { session?: TSmartdataOrdinarySession; ordered?: boolean; timeoutMS?: number }
|
|
2529
2535
|
): Promise<plugins.mongodb.InsertManyResult> {
|
|
2530
2536
|
if (!Array.isArray(dbDocsArg) || dbDocsArg.length === 0) {
|
|
2531
2537
|
throw new SmartdataPersistenceError(
|
|
@@ -2541,19 +2547,19 @@ export class SmartdataCollection<T> {
|
|
|
2541
2547
|
}
|
|
2542
2548
|
return this.runWithOrdinarySession(
|
|
2543
2549
|
opts?.session,
|
|
2544
|
-
true,
|
|
2545
|
-
async (rawSessionArg) => {
|
|
2546
|
-
await this.init();
|
|
2550
|
+
{ ordinaryWrite: true, timeoutMS: opts?.timeoutMS },
|
|
2551
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2552
|
+
await deadlineArg.join(this.init());
|
|
2547
2553
|
for (const dbDocArg of dbDocsArg) {
|
|
2548
2554
|
await this.checkDoc(dbDocArg);
|
|
2549
2555
|
}
|
|
2550
2556
|
const firstDocument = dbDocsArg[0];
|
|
2551
|
-
await this.markUniqueIndexes(firstDocument.uniqueIndexes);
|
|
2557
|
+
await this.markUniqueIndexes(firstDocument.uniqueIndexes, deadlineArg);
|
|
2552
2558
|
if (
|
|
2553
2559
|
firstDocument.regularIndexes
|
|
2554
2560
|
&& firstDocument.regularIndexes.length > 0
|
|
2555
2561
|
) {
|
|
2556
|
-
await this.createRegularIndexes(firstDocument.regularIndexes);
|
|
2562
|
+
await this.createRegularIndexes(firstDocument.regularIndexes, deadlineArg);
|
|
2557
2563
|
}
|
|
2558
2564
|
const saveableObjects: any[] = preparedObjects ?? [];
|
|
2559
2565
|
if (!preparedObjects) {
|
|
@@ -2565,6 +2571,7 @@ export class SmartdataCollection<T> {
|
|
|
2565
2571
|
return await this.mongoDbCollection.insertMany(saveableObjects, {
|
|
2566
2572
|
session: rawSessionArg,
|
|
2567
2573
|
ordered: opts?.ordered !== false,
|
|
2574
|
+
...deadlineArg.commandOptions(),
|
|
2568
2575
|
});
|
|
2569
2576
|
} catch (err: any) {
|
|
2570
2577
|
return normalizeOrdinaryPersistenceError(
|
|
@@ -2597,11 +2604,14 @@ export class SmartdataCollection<T> {
|
|
|
2597
2604
|
}
|
|
2598
2605
|
prepared.push(plugins.mongodb.BSON.deserialize(bson));
|
|
2599
2606
|
}
|
|
2600
|
-
return this.runWithOrdinarySession(optsArg.session,
|
|
2601
|
-
|
|
2607
|
+
return this.runWithOrdinarySession(optsArg.session, {
|
|
2608
|
+
ordinaryWrite: true,
|
|
2609
|
+
timeoutMS: optsArg.timeoutMS,
|
|
2610
|
+
}, async (rawSessionArg, deadlineArg) => {
|
|
2611
|
+
await deadlineArg.join(this.init());
|
|
2602
2612
|
const first = documentsArg[0];
|
|
2603
|
-
await this.markUniqueIndexes(first.uniqueIndexes);
|
|
2604
|
-
await this.createRegularIndexes(first.regularIndexes || []);
|
|
2613
|
+
await this.markUniqueIndexes(first.uniqueIndexes, deadlineArg);
|
|
2614
|
+
await this.createRegularIndexes(first.regularIndexes || [], deadlineArg);
|
|
2605
2615
|
// A document keyed by its identity is addressed through _id, and the
|
|
2606
2616
|
// seeded body must not repeat the immutable primary key: MongoDB derives
|
|
2607
2617
|
// it from the filter's equality condition on the insert branch.
|
|
@@ -2618,7 +2628,7 @@ export class SmartdataCollection<T> {
|
|
|
2618
2628
|
upsert: true,
|
|
2619
2629
|
},
|
|
2620
2630
|
};
|
|
2621
|
-
}), { ordered: false, session: rawSessionArg,
|
|
2631
|
+
}), { ordered: false, session: rawSessionArg, ...deadlineArg.commandOptions() });
|
|
2622
2632
|
if (result.upsertedCount + result.matchedCount !== prepared.length) {
|
|
2623
2633
|
throw new SmartdataPersistenceError('unsupported_operation',
|
|
2624
2634
|
'insertManyIfAbsent requires an acknowledged result for every identity.');
|
|
@@ -2636,7 +2646,7 @@ export class SmartdataCollection<T> {
|
|
|
2636
2646
|
*/
|
|
2637
2647
|
public async update(
|
|
2638
2648
|
dbDocArg: T & SmartDataDbDoc<T, unknown>,
|
|
2639
|
-
opts?: { session?: TSmartdataOrdinarySession }
|
|
2649
|
+
opts?: { session?: TSmartdataOrdinarySession; timeoutMS?: number }
|
|
2640
2650
|
): Promise<any> {
|
|
2641
2651
|
if (this.modelSchema?.ordinaryPersistence) {
|
|
2642
2652
|
throw new SmartdataPersistenceError('unsupported_operation',
|
|
@@ -2644,13 +2654,13 @@ export class SmartdataCollection<T> {
|
|
|
2644
2654
|
}
|
|
2645
2655
|
return this.runWithOrdinarySession(
|
|
2646
2656
|
opts?.session,
|
|
2647
|
-
true,
|
|
2648
|
-
async (rawSessionArg) => {
|
|
2649
|
-
await this.init();
|
|
2657
|
+
{ ordinaryWrite: true, timeoutMS: opts?.timeoutMS },
|
|
2658
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2659
|
+
await deadlineArg.join(this.init());
|
|
2650
2660
|
await this.checkDoc(dbDocArg);
|
|
2651
|
-
await this.markUniqueIndexes(dbDocArg.uniqueIndexes);
|
|
2661
|
+
await this.markUniqueIndexes(dbDocArg.uniqueIndexes, deadlineArg);
|
|
2652
2662
|
if (dbDocArg.regularIndexes && dbDocArg.regularIndexes.length > 0) {
|
|
2653
|
-
await this.createRegularIndexes(dbDocArg.regularIndexes);
|
|
2663
|
+
await this.createRegularIndexes(dbDocArg.regularIndexes, deadlineArg);
|
|
2654
2664
|
}
|
|
2655
2665
|
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
|
2656
2666
|
this.assertConstrainingIdentifiableObject(identifiableObject, 'update');
|
|
@@ -2683,7 +2693,7 @@ export class SmartdataCollection<T> {
|
|
|
2683
2693
|
? { $setOnInsert: insertOnlyObject }
|
|
2684
2694
|
: {}),
|
|
2685
2695
|
},
|
|
2686
|
-
{ upsert: true, session: rawSessionArg },
|
|
2696
|
+
{ upsert: true, session: rawSessionArg, ...deadlineArg.commandOptions() },
|
|
2687
2697
|
);
|
|
2688
2698
|
} catch (errorArg) {
|
|
2689
2699
|
return normalizeOrdinaryPersistenceError(
|
|
@@ -2697,18 +2707,19 @@ export class SmartdataCollection<T> {
|
|
|
2697
2707
|
|
|
2698
2708
|
public async delete(
|
|
2699
2709
|
dbDocArg: T & SmartDataDbDoc<T, unknown>,
|
|
2700
|
-
opts?: { session?: TSmartdataOrdinarySession }
|
|
2710
|
+
opts?: { session?: TSmartdataOrdinarySession; timeoutMS?: number }
|
|
2701
2711
|
): Promise<any> {
|
|
2702
2712
|
return this.runWithOrdinarySession(
|
|
2703
2713
|
opts?.session,
|
|
2704
|
-
true,
|
|
2705
|
-
async (rawSessionArg) => {
|
|
2706
|
-
await this.init();
|
|
2714
|
+
{ ordinaryWrite: true, timeoutMS: opts?.timeoutMS },
|
|
2715
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2716
|
+
await deadlineArg.join(this.init());
|
|
2707
2717
|
await this.checkDoc(dbDocArg);
|
|
2708
2718
|
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
|
2709
2719
|
this.assertConstrainingIdentifiableObject(identifiableObject, 'delete');
|
|
2710
2720
|
return this.mongoDbCollection.deleteOne(identifiableObject, {
|
|
2711
2721
|
session: rawSessionArg,
|
|
2722
|
+
...deadlineArg.commandOptions(),
|
|
2712
2723
|
});
|
|
2713
2724
|
},
|
|
2714
2725
|
);
|
|
@@ -2755,10 +2766,9 @@ export class SmartdataCollection<T> {
|
|
|
2755
2766
|
}
|
|
2756
2767
|
return this.runWithOrdinarySession(
|
|
2757
2768
|
opts?.session,
|
|
2758
|
-
false,
|
|
2759
|
-
async (rawSessionArg) => {
|
|
2760
|
-
await this.init();
|
|
2761
|
-
opts?.signal?.throwIfAborted();
|
|
2769
|
+
{ ordinaryWrite: false, timeoutMS: opts?.timeoutMS, signal: opts?.signal },
|
|
2770
|
+
async (rawSessionArg, deadlineArg) => {
|
|
2771
|
+
await deadlineArg.join(this.init());
|
|
2762
2772
|
const pipeline: plugins.mongodb.Document[] = [{ $match: filterObject }];
|
|
2763
2773
|
if (opts?.limit !== undefined) {
|
|
2764
2774
|
pipeline.push({ $limit: opts.limit });
|
|
@@ -2767,13 +2777,12 @@ export class SmartdataCollection<T> {
|
|
|
2767
2777
|
const cursor = this.mongoDbCollection.aggregate<{ count: number }>(pipeline, {
|
|
2768
2778
|
hint: opts?.hint,
|
|
2769
2779
|
maxTimeMS: opts?.maxTimeMS,
|
|
2770
|
-
|
|
2771
|
-
signal: opts?.signal,
|
|
2780
|
+
...deadlineArg.commandOptions(),
|
|
2772
2781
|
session: rawSessionArg,
|
|
2773
2782
|
});
|
|
2774
2783
|
return runCursorOperation(cursor, async (cursorArg) =>
|
|
2775
2784
|
(await cursorArg.next())?.count ?? 0,
|
|
2776
|
-
|
|
2785
|
+
deadlineArg.signal);
|
|
2777
2786
|
},
|
|
2778
2787
|
);
|
|
2779
2788
|
}
|
package/ts/nosqldb/classes.db.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from './classes.namespaceinspection.js';
|
|
19
19
|
|
|
20
20
|
export { SmartdataSession } from './classes.session.js';
|
|
21
|
-
export type { TSmartdataOrdinarySession } from './classes.session.js';
|
|
21
|
+
export type { ISmartdataTransactionOptions, TSmartdataOrdinarySession } from './classes.session.js';
|
|
22
22
|
|
|
23
23
|
import { logger } from './logging.js';
|
|
24
24
|
import { assertDataOptions, SmartdataOperationBudget } from './classes.operationbudget.js';
|