@lossless.org/client 1.23.1 → 1.23.2
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.js +3 -3
- package/dist_ts/nosqldb/classes.atomicfindoneandupdate.js +12 -5
- package/dist_ts/nosqldb/classes.atomicupdate.js +4 -4
- package/dist_ts/nosqldb/classes.collection.js +3 -3
- package/dist_ts/nosqldb/classes.exactpersistence.js +3 -3
- package/dist_ts/nosqldb/classes.readtracker.d.ts +6 -0
- package/dist_ts/nosqldb/classes.readtracker.js +10 -1
- package/dist_ts/nosqldb/classes.session.d.ts +5 -2
- package/dist_ts/nosqldb/classes.session.js +13 -6
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/nosqldb/classes.atomicdelete.ts +2 -2
- package/ts/nosqldb/classes.atomicfindoneandupdate.ts +11 -6
- package/ts/nosqldb/classes.atomicupdate.ts +3 -4
- package/ts/nosqldb/classes.collection.ts +2 -2
- package/ts/nosqldb/classes.exactpersistence.ts +2 -2
- package/ts/nosqldb/classes.readtracker.ts +10 -0
- package/ts/nosqldb/classes.session.ts +13 -6
|
@@ -1956,7 +1956,7 @@ export class SmartdataExactCollection<
|
|
|
1956
1956
|
// the write-revision partition it held is read first.
|
|
1957
1957
|
const previousPartitionsRead = current._smartdataRevision === undefined
|
|
1958
1958
|
&& await readPreviousWriteRevisions(
|
|
1959
|
-
this.collection
|
|
1959
|
+
this.collection, sessionArg, selector, deadlineArg,
|
|
1960
1960
|
);
|
|
1961
1961
|
const reportTransition = (): void => {
|
|
1962
1962
|
reportSmartdataCollectionWrite(
|
|
@@ -2064,7 +2064,7 @@ export class SmartdataExactCollection<
|
|
|
2064
2064
|
};
|
|
2065
2065
|
const previousPartitionsRead = current._smartdataRevision === undefined
|
|
2066
2066
|
&& await readPreviousWriteRevisions(
|
|
2067
|
-
this.collection
|
|
2067
|
+
this.collection, sessionArg, selector, deadlineArg,
|
|
2068
2068
|
);
|
|
2069
2069
|
let result: plugins.mongodb.DeleteResult;
|
|
2070
2070
|
const deleteOptions = { session: sessionArg, ...deadlineArg.commandOptions() };
|
|
@@ -1162,6 +1162,16 @@ export const captureSmartdataCollectionChange = (
|
|
|
1162
1162
|
return () => applyChanges(dbArg, collectionArg, [{ kind: 'unknown', touched: 'all', startedAt: 0 }]);
|
|
1163
1163
|
};
|
|
1164
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* @internal Whether an update by operators leaves a field as each document it
|
|
1167
|
+
* updates held it: no operator names the field or a path through it. An update
|
|
1168
|
+
* the tracker cannot follow may change any field.
|
|
1169
|
+
*/
|
|
1170
|
+
export const updateLeavesField = (updateArg: unknown, fieldArg: string): boolean => {
|
|
1171
|
+
const { touched } = analyzeUpdate(updateArg, false);
|
|
1172
|
+
return touched !== 'all' && ![...touched].some((pathArg) => pathsOverlap(pathArg, fieldArg));
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1165
1175
|
/**
|
|
1166
1176
|
* @internal The write-revision counters one acknowledged write bumps: the
|
|
1167
1177
|
* partition of each document state it names before and after, and the shared
|
|
@@ -1067,19 +1067,26 @@ const bumpTransactionRevisions = (
|
|
|
1067
1067
|
* documents a write by selector is about to change, and returns whether it
|
|
1068
1068
|
* did; the write's report then states `previousPartitionsRead`. `false` when
|
|
1069
1069
|
* the database keeps no revisions or the write runs outside an owned
|
|
1070
|
-
* transaction.
|
|
1070
|
+
* transaction. `false` without a read, too, when the collection's model
|
|
1071
|
+
* persists no partition field: its documents count on the shared counter,
|
|
1072
|
+
* which the write's report bumps for each document state it cannot place, and
|
|
1073
|
+
* every read of the collection depends on that counter.
|
|
1071
1074
|
*/
|
|
1072
1075
|
export const readPreviousWriteRevisions = async (
|
|
1073
|
-
|
|
1074
|
-
collectionArg: plugins.mongodb.Collection<any>,
|
|
1076
|
+
collectionArg: SmartdataCollection<any>,
|
|
1075
1077
|
rawSessionArg: plugins.mongodb.ClientSession | undefined,
|
|
1076
1078
|
selectorArg: unknown,
|
|
1077
1079
|
deadlineArg: SmartdataOperationDeadline,
|
|
1078
1080
|
): Promise<boolean> => {
|
|
1079
|
-
|
|
1081
|
+
const owner = collectionArg.smartdataDb;
|
|
1082
|
+
if (!rawSessionArg || !isSmartdataWriteRevisionsActive(owner)) return false;
|
|
1080
1083
|
const binding = bindingsByRawSession.get(rawSessionArg);
|
|
1081
|
-
if (!binding?.transactionActive || binding.owner !==
|
|
1082
|
-
const
|
|
1084
|
+
if (!binding?.transactionActive || binding.owner !== owner) return false;
|
|
1085
|
+
const persistedFields = collectionArg.getBoundModelSchema()?.persistedFields;
|
|
1086
|
+
if (persistedFields && !persistedFields.includes(writeRevisionsPartitionField(owner)!)) return false;
|
|
1087
|
+
const ids = await readPreviousRevisionIds(
|
|
1088
|
+
owner, collectionArg.mongoDbCollection, rawSessionArg, selectorArg, deadlineArg,
|
|
1089
|
+
);
|
|
1083
1090
|
bumpTransactionRevisions(binding, ids);
|
|
1084
1091
|
return true;
|
|
1085
1092
|
};
|