@atscript/db-mongo 0.1.176 → 0.1.177
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/index.cjs +8 -3
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +8 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2460,11 +2460,16 @@ var MongoAdapter = class MongoAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
2460
2460
|
* snapshot, which satisfies `'read committed'` and `'repeatable read'`;
|
|
2461
2461
|
* `'serializable'` throws `ISOLATION_NOT_SUPPORTED` (snapshot isolation
|
|
2462
2462
|
* allows write skew), and so does any level where `fn` would run without
|
|
2463
|
-
* a transaction.
|
|
2463
|
+
* a transaction. A nested call under `join: 'atLeast'` joins with no level
|
|
2464
|
+
* check (the snapshot satisfies both levels); `join: 'same'` (since
|
|
2465
|
+
* 0.1.177) is checked as on every adapter.
|
|
2464
2466
|
*/
|
|
2465
2467
|
async withTransaction(fn, opts) {
|
|
2466
2468
|
const isolation = this._checkIsolation(opts);
|
|
2467
|
-
if (this._getTransactionState())
|
|
2469
|
+
if (this._getTransactionState()) {
|
|
2470
|
+
if (opts?.join === "same") this._checkJoin(isolation, "same");
|
|
2471
|
+
return fn();
|
|
2472
|
+
}
|
|
2468
2473
|
const passThrough = (reason) => {
|
|
2469
2474
|
if (isolation) throw this._isolationNotSupported(`Isolation '${isolation}' needs a MongoDB transaction — ${reason}`);
|
|
2470
2475
|
return fn();
|
|
@@ -2475,7 +2480,7 @@ var MongoAdapter = class MongoAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
2475
2480
|
try {
|
|
2476
2481
|
let result;
|
|
2477
2482
|
await session.withTransaction(async () => {
|
|
2478
|
-
result = await this._runInTransactionContext(session, fn);
|
|
2483
|
+
result = await this._runInTransactionContext(session, fn, isolation);
|
|
2479
2484
|
});
|
|
2480
2485
|
return result;
|
|
2481
2486
|
} catch (error) {
|
package/dist/index.d.cts
CHANGED
|
@@ -336,7 +336,9 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
336
336
|
* snapshot, which satisfies `'read committed'` and `'repeatable read'`;
|
|
337
337
|
* `'serializable'` throws `ISOLATION_NOT_SUPPORTED` (snapshot isolation
|
|
338
338
|
* allows write skew), and so does any level where `fn` would run without
|
|
339
|
-
* a transaction.
|
|
339
|
+
* a transaction. A nested call under `join: 'atLeast'` joins with no level
|
|
340
|
+
* check (the snapshot satisfies both levels); `join: 'same'` (since
|
|
341
|
+
* 0.1.177) is checked as on every adapter.
|
|
340
342
|
*/
|
|
341
343
|
withTransaction<T>(fn: () => Promise<T>, opts?: TTransactionOptions): Promise<T>;
|
|
342
344
|
private static readonly _ISOLATION_LEVELS;
|
package/dist/index.d.mts
CHANGED
|
@@ -336,7 +336,9 @@ declare class MongoAdapter extends BaseDbAdapter {
|
|
|
336
336
|
* snapshot, which satisfies `'read committed'` and `'repeatable read'`;
|
|
337
337
|
* `'serializable'` throws `ISOLATION_NOT_SUPPORTED` (snapshot isolation
|
|
338
338
|
* allows write skew), and so does any level where `fn` would run without
|
|
339
|
-
* a transaction.
|
|
339
|
+
* a transaction. A nested call under `join: 'atLeast'` joins with no level
|
|
340
|
+
* check (the snapshot satisfies both levels); `join: 'same'` (since
|
|
341
|
+
* 0.1.177) is checked as on every adapter.
|
|
340
342
|
*/
|
|
341
343
|
withTransaction<T>(fn: () => Promise<T>, opts?: TTransactionOptions): Promise<T>;
|
|
342
344
|
private static readonly _ISOLATION_LEVELS;
|
package/dist/index.mjs
CHANGED
|
@@ -2459,11 +2459,16 @@ var MongoAdapter = class MongoAdapter extends BaseDbAdapter {
|
|
|
2459
2459
|
* snapshot, which satisfies `'read committed'` and `'repeatable read'`;
|
|
2460
2460
|
* `'serializable'` throws `ISOLATION_NOT_SUPPORTED` (snapshot isolation
|
|
2461
2461
|
* allows write skew), and so does any level where `fn` would run without
|
|
2462
|
-
* a transaction.
|
|
2462
|
+
* a transaction. A nested call under `join: 'atLeast'` joins with no level
|
|
2463
|
+
* check (the snapshot satisfies both levels); `join: 'same'` (since
|
|
2464
|
+
* 0.1.177) is checked as on every adapter.
|
|
2463
2465
|
*/
|
|
2464
2466
|
async withTransaction(fn, opts) {
|
|
2465
2467
|
const isolation = this._checkIsolation(opts);
|
|
2466
|
-
if (this._getTransactionState())
|
|
2468
|
+
if (this._getTransactionState()) {
|
|
2469
|
+
if (opts?.join === "same") this._checkJoin(isolation, "same");
|
|
2470
|
+
return fn();
|
|
2471
|
+
}
|
|
2467
2472
|
const passThrough = (reason) => {
|
|
2468
2473
|
if (isolation) throw this._isolationNotSupported(`Isolation '${isolation}' needs a MongoDB transaction — ${reason}`);
|
|
2469
2474
|
return fn();
|
|
@@ -2474,7 +2479,7 @@ var MongoAdapter = class MongoAdapter extends BaseDbAdapter {
|
|
|
2474
2479
|
try {
|
|
2475
2480
|
let result;
|
|
2476
2481
|
await session.withTransaction(async () => {
|
|
2477
|
-
result = await this._runInTransactionContext(session, fn);
|
|
2482
|
+
result = await this._runInTransactionContext(session, fn, isolation);
|
|
2478
2483
|
});
|
|
2479
2484
|
return result;
|
|
2480
2485
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mongo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.177",
|
|
4
4
|
"description": "Mongodb plugin for atscript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@atscript/typescript": "^0.2.12",
|
|
59
59
|
"@uniqu/core": "^0.2.2",
|
|
60
60
|
"mongodb": "^6.17.0",
|
|
61
|
-
"@atscript/db": "^0.1.
|
|
61
|
+
"@atscript/db": "^0.1.177"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "vp pack",
|