@atscript/db-memory 0.1.139 → 0.1.141
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 +19 -53
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +17 -51
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -4,26 +4,6 @@ let _atscript_db_agg = require("@atscript/db/agg");
|
|
|
4
4
|
let _uniqu_core = require("@uniqu/core");
|
|
5
5
|
//#region src/lib/memory-filter.ts
|
|
6
6
|
/**
|
|
7
|
-
* Dot-path getter. Splits `path` on `.` and walks plain objects, returning the
|
|
8
|
-
* value at the end of the path or `undefined` if any intermediate segment is
|
|
9
|
-
* missing or is not a plain object.
|
|
10
|
-
*
|
|
11
|
-
* LIMITATION (v1, accepted): this does NOT descend into arrays. If a segment
|
|
12
|
-
* resolves to an array, traversal stops and `undefined` is returned — there is
|
|
13
|
-
* no positional/`$elemMatch`-style indexing. Array-of-object matching is a
|
|
14
|
-
* later concern; the SQL/Mongo adapters flatten differently and we do not want
|
|
15
|
-
* to fake a semantic the store can't back yet.
|
|
16
|
-
*/
|
|
17
|
-
function getPath(row, path) {
|
|
18
|
-
const segments = path.split(".");
|
|
19
|
-
let current = row;
|
|
20
|
-
for (const seg of segments) {
|
|
21
|
-
if (current === null || typeof current !== "object" || Array.isArray(current)) return;
|
|
22
|
-
current = current[seg];
|
|
23
|
-
}
|
|
24
|
-
return current;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
7
|
* {@link getPath} compiled for one path: split once, and a single segment is
|
|
28
8
|
* a direct property read — for callers that read the same path off many rows.
|
|
29
9
|
*/
|
|
@@ -93,7 +73,7 @@ function stringifyLeaf(v) {
|
|
|
93
73
|
}
|
|
94
74
|
/** `$eq` semantics, factored out so `$ne` can be its exact negation. */
|
|
95
75
|
function evalEq(row, field, value) {
|
|
96
|
-
const fieldValue = getPath(row, field);
|
|
76
|
+
const fieldValue = (0, _atscript_db.getPath)(row, field);
|
|
97
77
|
if (value === null) return fieldValue == null;
|
|
98
78
|
if (value instanceof RegExp) return fieldValue != null && value.test(stringifyLeaf(fieldValue));
|
|
99
79
|
return valuesEqual(fieldValue, value);
|
|
@@ -101,7 +81,7 @@ function evalEq(row, field, value) {
|
|
|
101
81
|
/** `$in` membership, factored out so `$nin` can be its exact negation. */
|
|
102
82
|
function evalIn(row, field, value) {
|
|
103
83
|
if (!Array.isArray(value)) return false;
|
|
104
|
-
const fieldValue = getPath(row, field);
|
|
84
|
+
const fieldValue = (0, _atscript_db.getPath)(row, field);
|
|
105
85
|
return value.some((element) => valuesEqual(fieldValue, element));
|
|
106
86
|
}
|
|
107
87
|
/**
|
|
@@ -121,7 +101,7 @@ function toOrdinal(v) {
|
|
|
121
101
|
* differs from SQL engines' collated ordering.
|
|
122
102
|
*/
|
|
123
103
|
function evalRelational(row, field, op, value) {
|
|
124
|
-
const fieldValue = getPath(row, field);
|
|
104
|
+
const fieldValue = (0, _atscript_db.getPath)(row, field);
|
|
125
105
|
if (fieldValue === void 0 || fieldValue === null) return false;
|
|
126
106
|
const a = toOrdinal(fieldValue);
|
|
127
107
|
const b = toOrdinal(value);
|
|
@@ -166,7 +146,7 @@ const memoryVisitor = {
|
|
|
166
146
|
const { pattern, flags } = parseRegexString(value);
|
|
167
147
|
const regex = new RegExp(pattern, flags);
|
|
168
148
|
return (row) => {
|
|
169
|
-
const fieldValue = getPath(row, field);
|
|
149
|
+
const fieldValue = (0, _atscript_db.getPath)(row, field);
|
|
170
150
|
return fieldValue != null && regex.test(stringifyLeaf(fieldValue));
|
|
171
151
|
};
|
|
172
152
|
}
|
|
@@ -200,9 +180,9 @@ function buildMemoryPredicate(filter) {
|
|
|
200
180
|
* instead of hand-rolling a second copy. The adapter wires its own PK-derived
|
|
201
181
|
* tie-break / physical-PK fields in as parameters.
|
|
202
182
|
*
|
|
203
|
-
*
|
|
204
|
-
* the dot-path WRITE
|
|
205
|
-
* here because projection (and the adapter's update path) are
|
|
183
|
+
* The dot-path READ / DELETE helpers (`getPath` / `deletePath`) are the
|
|
184
|
+
* core's (`@atscript/db`); the dot-path WRITE helper ({@link setPath}) lives
|
|
185
|
+
* here because projection (and the adapter's update path) are its only users.
|
|
206
186
|
*/
|
|
207
187
|
/**
|
|
208
188
|
* Total ordering for `$sort`. `null`/`undefined` sort LOW (before any concrete
|
|
@@ -240,20 +220,6 @@ function setPath(target, path, value) {
|
|
|
240
220
|
current[segments[segments.length - 1]] = value;
|
|
241
221
|
}
|
|
242
222
|
/**
|
|
243
|
-
* Dot-path deleter used by exclusion projection. No-op when any intermediate
|
|
244
|
-
* segment is missing or not a plain object. Top-level keys and nested dot-paths
|
|
245
|
-
* both work.
|
|
246
|
-
*/
|
|
247
|
-
function deletePath(target, path) {
|
|
248
|
-
const segments = path.split(".");
|
|
249
|
-
let current = target;
|
|
250
|
-
for (let i = 0; i < segments.length - 1; i++) {
|
|
251
|
-
if (current === null || typeof current !== "object" || Array.isArray(current)) return;
|
|
252
|
-
current = current[segments[i]];
|
|
253
|
-
}
|
|
254
|
-
if (current !== null && typeof current === "object" && !Array.isArray(current)) delete current[segments[segments.length - 1]];
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
223
|
* Stable multi-key sort from `$sort`, applied over plain rows.
|
|
258
224
|
*
|
|
259
225
|
* - No `$sort` (or an empty one) → returns the input array UNCHANGED (same
|
|
@@ -278,7 +244,7 @@ function sortRows(rows, $sort, tieBreak) {
|
|
|
278
244
|
tie: tieBreak?.(row)
|
|
279
245
|
})).toSorted((a, b) => {
|
|
280
246
|
for (const [field, dir] of keys) {
|
|
281
|
-
const cmp = compareLeaves(getPath(a.row, field), getPath(b.row, field));
|
|
247
|
+
const cmp = compareLeaves((0, _atscript_db.getPath)(a.row, field), (0, _atscript_db.getPath)(b.row, field));
|
|
282
248
|
if (cmp !== 0) return dir === -1 ? -cmp : cmp;
|
|
283
249
|
}
|
|
284
250
|
if (tieBreak) {
|
|
@@ -326,13 +292,13 @@ function projectRow(row, projection, opts) {
|
|
|
326
292
|
for (const pk of opts?.pkFields ?? []) paths.add(pk);
|
|
327
293
|
const out = {};
|
|
328
294
|
for (const path of paths) {
|
|
329
|
-
const value = getPath(row, path);
|
|
295
|
+
const value = (0, _atscript_db.getPath)(row, path);
|
|
330
296
|
if (value !== void 0) setPath(out, path, value);
|
|
331
297
|
}
|
|
332
298
|
return clone ? structuredClone(out) : out;
|
|
333
299
|
}
|
|
334
300
|
const out = structuredClone(row);
|
|
335
|
-
for (const [path, v] of entries) if (v === 0) deletePath(out, path);
|
|
301
|
+
for (const [path, v] of entries) if (v === 0) (0, _atscript_db.deletePath)(out, path);
|
|
336
302
|
return out;
|
|
337
303
|
}
|
|
338
304
|
//#endregion
|
|
@@ -767,7 +733,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
767
733
|
* `['a:b','c']` differ, and `1` differs from `'1'`.
|
|
768
734
|
*/
|
|
769
735
|
pkKey(row) {
|
|
770
|
-
const values = this._physicalPkFields().map((field) => getPath(row, field));
|
|
736
|
+
const values = this._physicalPkFields().map((field) => (0, _atscript_db.getPath)(row, field));
|
|
771
737
|
return JSON.stringify(values);
|
|
772
738
|
}
|
|
773
739
|
/**
|
|
@@ -788,7 +754,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
788
754
|
*/
|
|
789
755
|
_compositeInsertedId(row) {
|
|
790
756
|
const id = {};
|
|
791
|
-
for (const field of this._physicalPkFields()) id[field] = getPath(row, field);
|
|
757
|
+
for (const field of this._physicalPkFields()) id[field] = (0, _atscript_db.getPath)(row, field);
|
|
792
758
|
return id;
|
|
793
759
|
}
|
|
794
760
|
/**
|
|
@@ -851,7 +817,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
851
817
|
*/
|
|
852
818
|
_insertRow(state, data) {
|
|
853
819
|
const row = structuredClone(data);
|
|
854
|
-
const versionColumn = this._table.
|
|
820
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
855
821
|
if (versionColumn !== void 0 && !(versionColumn in row)) row[versionColumn] = 0;
|
|
856
822
|
this._applyIncrements(state.incrementCounters, row);
|
|
857
823
|
const key = this.pkKey(row);
|
|
@@ -875,7 +841,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
875
841
|
const tuple = [];
|
|
876
842
|
let skip = false;
|
|
877
843
|
for (const field of index.fields) {
|
|
878
|
-
const value = getPath(row, field);
|
|
844
|
+
const value = (0, _atscript_db.getPath)(row, field);
|
|
879
845
|
if (index.optionalFields.has(field) && (value === null || value === void 0)) {
|
|
880
846
|
skip = true;
|
|
881
847
|
break;
|
|
@@ -886,7 +852,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
886
852
|
for (const [existingKey, existing] of state.rows) {
|
|
887
853
|
if (excludeKey !== void 0 && existingKey === excludeKey) continue;
|
|
888
854
|
let equal = true;
|
|
889
|
-
for (let i = 0; i < index.fields.length; i++) if (!valuesEqual(getPath(existing, index.fields[i]), tuple[i])) {
|
|
855
|
+
for (let i = 0; i < index.fields.length; i++) if (!valuesEqual((0, _atscript_db.getPath)(existing, index.fields[i]), tuple[i])) {
|
|
890
856
|
equal = false;
|
|
891
857
|
break;
|
|
892
858
|
}
|
|
@@ -927,7 +893,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
927
893
|
* does not exist (`state` undefined) matches nothing and is not created.
|
|
928
894
|
*/
|
|
929
895
|
_selectForWrite(state, filter, expectedVersion, many) {
|
|
930
|
-
const versionColumn = this._table.
|
|
896
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
931
897
|
if (expectedVersion !== void 0 && versionColumn === void 0) throw new Error("expectedVersion requires a versioned table");
|
|
932
898
|
const match = buildMemoryPredicate(filter);
|
|
933
899
|
const matched = [];
|
|
@@ -952,7 +918,7 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
952
918
|
* {@link replaceOne} (full-replace path).
|
|
953
919
|
*/
|
|
954
920
|
_bumpVersion(target, oldRow) {
|
|
955
|
-
const versionColumn = this._table.
|
|
921
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
956
922
|
if (versionColumn !== void 0) target[versionColumn] = (oldRow[versionColumn] ?? 0) + 1;
|
|
957
923
|
}
|
|
958
924
|
/**
|
|
@@ -977,8 +943,8 @@ var MemoryAdapter = class extends _atscript_db.BaseDbAdapter {
|
|
|
977
943
|
_applyUpdate(row, data, ops) {
|
|
978
944
|
const patch = structuredClone(data);
|
|
979
945
|
for (const k of Object.keys(patch)) setPath(row, k, patch[k]);
|
|
980
|
-
if (ops?.inc) for (const [col, n] of Object.entries(ops.inc)) setPath(row, col, (Number(getPath(row, col)) || 0) + n);
|
|
981
|
-
if (ops?.mul) for (const [col, n] of Object.entries(ops.mul)) setPath(row, col, (Number(getPath(row, col)) || 0) * n);
|
|
946
|
+
if (ops?.inc) for (const [col, n] of Object.entries(ops.inc)) setPath(row, col, (Number((0, _atscript_db.getPath)(row, col)) || 0) + n);
|
|
947
|
+
if (ops?.mul) for (const [col, n] of Object.entries(ops.mul)) setPath(row, col, (Number((0, _atscript_db.getPath)(row, col)) || 0) * n);
|
|
982
948
|
}
|
|
983
949
|
/**
|
|
984
950
|
* Places `next` into the store under its (possibly changed) {@link pkKey},
|
package/dist/index.d.cts
CHANGED
|
@@ -438,7 +438,7 @@ declare function setMemoryProvider(space: DbSpace, type: TAtscriptAnnotatedType,
|
|
|
438
438
|
*/
|
|
439
439
|
type Predicate = (row: Record<string, unknown>) => boolean;
|
|
440
440
|
/**
|
|
441
|
-
* Dot-path getter
|
|
441
|
+
* Dot-path getter — the core's `getPath`: walks plain objects, returning the
|
|
442
442
|
* value at the end of the path or `undefined` if any intermediate segment is
|
|
443
443
|
* missing or is not a plain object.
|
|
444
444
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -438,7 +438,7 @@ declare function setMemoryProvider(space: DbSpace, type: TAtscriptAnnotatedType,
|
|
|
438
438
|
*/
|
|
439
439
|
type Predicate = (row: Record<string, unknown>) => boolean;
|
|
440
440
|
/**
|
|
441
|
-
* Dot-path getter
|
|
441
|
+
* Dot-path getter — the core's `getPath`: walks plain objects, returning the
|
|
442
442
|
* value at the end of the path or `undefined` if any intermediate segment is
|
|
443
443
|
* missing or is not a plain object.
|
|
444
444
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, BaseDbAdapter, DbError, DbSpace, isAtscriptDbView, walkFilter } from "@atscript/db";
|
|
1
|
+
import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, BaseDbAdapter, DbError, DbSpace, deletePath, getPath, getPath as getPath$1, isAtscriptDbView, walkFilter } from "@atscript/db";
|
|
2
2
|
import { assertAggregateFn, resolveAlias } from "@atscript/db/agg";
|
|
3
3
|
import { bucketer } from "@uniqu/core";
|
|
4
4
|
//#region src/lib/memory-filter.ts
|
|
5
5
|
/**
|
|
6
|
-
* Dot-path getter. Splits `path` on `.` and walks plain objects, returning the
|
|
7
|
-
* value at the end of the path or `undefined` if any intermediate segment is
|
|
8
|
-
* missing or is not a plain object.
|
|
9
|
-
*
|
|
10
|
-
* LIMITATION (v1, accepted): this does NOT descend into arrays. If a segment
|
|
11
|
-
* resolves to an array, traversal stops and `undefined` is returned — there is
|
|
12
|
-
* no positional/`$elemMatch`-style indexing. Array-of-object matching is a
|
|
13
|
-
* later concern; the SQL/Mongo adapters flatten differently and we do not want
|
|
14
|
-
* to fake a semantic the store can't back yet.
|
|
15
|
-
*/
|
|
16
|
-
function getPath(row, path) {
|
|
17
|
-
const segments = path.split(".");
|
|
18
|
-
let current = row;
|
|
19
|
-
for (const seg of segments) {
|
|
20
|
-
if (current === null || typeof current !== "object" || Array.isArray(current)) return;
|
|
21
|
-
current = current[seg];
|
|
22
|
-
}
|
|
23
|
-
return current;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
6
|
* {@link getPath} compiled for one path: split once, and a single segment is
|
|
27
7
|
* a direct property read — for callers that read the same path off many rows.
|
|
28
8
|
*/
|
|
@@ -92,7 +72,7 @@ function stringifyLeaf(v) {
|
|
|
92
72
|
}
|
|
93
73
|
/** `$eq` semantics, factored out so `$ne` can be its exact negation. */
|
|
94
74
|
function evalEq(row, field, value) {
|
|
95
|
-
const fieldValue = getPath(row, field);
|
|
75
|
+
const fieldValue = getPath$1(row, field);
|
|
96
76
|
if (value === null) return fieldValue == null;
|
|
97
77
|
if (value instanceof RegExp) return fieldValue != null && value.test(stringifyLeaf(fieldValue));
|
|
98
78
|
return valuesEqual(fieldValue, value);
|
|
@@ -100,7 +80,7 @@ function evalEq(row, field, value) {
|
|
|
100
80
|
/** `$in` membership, factored out so `$nin` can be its exact negation. */
|
|
101
81
|
function evalIn(row, field, value) {
|
|
102
82
|
if (!Array.isArray(value)) return false;
|
|
103
|
-
const fieldValue = getPath(row, field);
|
|
83
|
+
const fieldValue = getPath$1(row, field);
|
|
104
84
|
return value.some((element) => valuesEqual(fieldValue, element));
|
|
105
85
|
}
|
|
106
86
|
/**
|
|
@@ -120,7 +100,7 @@ function toOrdinal(v) {
|
|
|
120
100
|
* differs from SQL engines' collated ordering.
|
|
121
101
|
*/
|
|
122
102
|
function evalRelational(row, field, op, value) {
|
|
123
|
-
const fieldValue = getPath(row, field);
|
|
103
|
+
const fieldValue = getPath$1(row, field);
|
|
124
104
|
if (fieldValue === void 0 || fieldValue === null) return false;
|
|
125
105
|
const a = toOrdinal(fieldValue);
|
|
126
106
|
const b = toOrdinal(value);
|
|
@@ -165,7 +145,7 @@ const memoryVisitor = {
|
|
|
165
145
|
const { pattern, flags } = parseRegexString(value);
|
|
166
146
|
const regex = new RegExp(pattern, flags);
|
|
167
147
|
return (row) => {
|
|
168
|
-
const fieldValue = getPath(row, field);
|
|
148
|
+
const fieldValue = getPath$1(row, field);
|
|
169
149
|
return fieldValue != null && regex.test(stringifyLeaf(fieldValue));
|
|
170
150
|
};
|
|
171
151
|
}
|
|
@@ -199,9 +179,9 @@ function buildMemoryPredicate(filter) {
|
|
|
199
179
|
* instead of hand-rolling a second copy. The adapter wires its own PK-derived
|
|
200
180
|
* tie-break / physical-PK fields in as parameters.
|
|
201
181
|
*
|
|
202
|
-
*
|
|
203
|
-
* the dot-path WRITE
|
|
204
|
-
* here because projection (and the adapter's update path) are
|
|
182
|
+
* The dot-path READ / DELETE helpers (`getPath` / `deletePath`) are the
|
|
183
|
+
* core's (`@atscript/db`); the dot-path WRITE helper ({@link setPath}) lives
|
|
184
|
+
* here because projection (and the adapter's update path) are its only users.
|
|
205
185
|
*/
|
|
206
186
|
/**
|
|
207
187
|
* Total ordering for `$sort`. `null`/`undefined` sort LOW (before any concrete
|
|
@@ -239,20 +219,6 @@ function setPath(target, path, value) {
|
|
|
239
219
|
current[segments[segments.length - 1]] = value;
|
|
240
220
|
}
|
|
241
221
|
/**
|
|
242
|
-
* Dot-path deleter used by exclusion projection. No-op when any intermediate
|
|
243
|
-
* segment is missing or not a plain object. Top-level keys and nested dot-paths
|
|
244
|
-
* both work.
|
|
245
|
-
*/
|
|
246
|
-
function deletePath(target, path) {
|
|
247
|
-
const segments = path.split(".");
|
|
248
|
-
let current = target;
|
|
249
|
-
for (let i = 0; i < segments.length - 1; i++) {
|
|
250
|
-
if (current === null || typeof current !== "object" || Array.isArray(current)) return;
|
|
251
|
-
current = current[segments[i]];
|
|
252
|
-
}
|
|
253
|
-
if (current !== null && typeof current === "object" && !Array.isArray(current)) delete current[segments[segments.length - 1]];
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
222
|
* Stable multi-key sort from `$sort`, applied over plain rows.
|
|
257
223
|
*
|
|
258
224
|
* - No `$sort` (or an empty one) → returns the input array UNCHANGED (same
|
|
@@ -766,7 +732,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
766
732
|
* `['a:b','c']` differ, and `1` differs from `'1'`.
|
|
767
733
|
*/
|
|
768
734
|
pkKey(row) {
|
|
769
|
-
const values = this._physicalPkFields().map((field) => getPath(row, field));
|
|
735
|
+
const values = this._physicalPkFields().map((field) => getPath$1(row, field));
|
|
770
736
|
return JSON.stringify(values);
|
|
771
737
|
}
|
|
772
738
|
/**
|
|
@@ -787,7 +753,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
787
753
|
*/
|
|
788
754
|
_compositeInsertedId(row) {
|
|
789
755
|
const id = {};
|
|
790
|
-
for (const field of this._physicalPkFields()) id[field] = getPath(row, field);
|
|
756
|
+
for (const field of this._physicalPkFields()) id[field] = getPath$1(row, field);
|
|
791
757
|
return id;
|
|
792
758
|
}
|
|
793
759
|
/**
|
|
@@ -850,7 +816,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
850
816
|
*/
|
|
851
817
|
_insertRow(state, data) {
|
|
852
818
|
const row = structuredClone(data);
|
|
853
|
-
const versionColumn = this._table.
|
|
819
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
854
820
|
if (versionColumn !== void 0 && !(versionColumn in row)) row[versionColumn] = 0;
|
|
855
821
|
this._applyIncrements(state.incrementCounters, row);
|
|
856
822
|
const key = this.pkKey(row);
|
|
@@ -874,7 +840,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
874
840
|
const tuple = [];
|
|
875
841
|
let skip = false;
|
|
876
842
|
for (const field of index.fields) {
|
|
877
|
-
const value = getPath(row, field);
|
|
843
|
+
const value = getPath$1(row, field);
|
|
878
844
|
if (index.optionalFields.has(field) && (value === null || value === void 0)) {
|
|
879
845
|
skip = true;
|
|
880
846
|
break;
|
|
@@ -885,7 +851,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
885
851
|
for (const [existingKey, existing] of state.rows) {
|
|
886
852
|
if (excludeKey !== void 0 && existingKey === excludeKey) continue;
|
|
887
853
|
let equal = true;
|
|
888
|
-
for (let i = 0; i < index.fields.length; i++) if (!valuesEqual(getPath(existing, index.fields[i]), tuple[i])) {
|
|
854
|
+
for (let i = 0; i < index.fields.length; i++) if (!valuesEqual(getPath$1(existing, index.fields[i]), tuple[i])) {
|
|
889
855
|
equal = false;
|
|
890
856
|
break;
|
|
891
857
|
}
|
|
@@ -926,7 +892,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
926
892
|
* does not exist (`state` undefined) matches nothing and is not created.
|
|
927
893
|
*/
|
|
928
894
|
_selectForWrite(state, filter, expectedVersion, many) {
|
|
929
|
-
const versionColumn = this._table.
|
|
895
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
930
896
|
if (expectedVersion !== void 0 && versionColumn === void 0) throw new Error("expectedVersion requires a versioned table");
|
|
931
897
|
const match = buildMemoryPredicate(filter);
|
|
932
898
|
const matched = [];
|
|
@@ -951,7 +917,7 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
951
917
|
* {@link replaceOne} (full-replace path).
|
|
952
918
|
*/
|
|
953
919
|
_bumpVersion(target, oldRow) {
|
|
954
|
-
const versionColumn = this._table.
|
|
920
|
+
const versionColumn = this._table.versionColumnPhysical;
|
|
955
921
|
if (versionColumn !== void 0) target[versionColumn] = (oldRow[versionColumn] ?? 0) + 1;
|
|
956
922
|
}
|
|
957
923
|
/**
|
|
@@ -976,8 +942,8 @@ var MemoryAdapter = class extends BaseDbAdapter {
|
|
|
976
942
|
_applyUpdate(row, data, ops) {
|
|
977
943
|
const patch = structuredClone(data);
|
|
978
944
|
for (const k of Object.keys(patch)) setPath(row, k, patch[k]);
|
|
979
|
-
if (ops?.inc) for (const [col, n] of Object.entries(ops.inc)) setPath(row, col, (Number(getPath(row, col)) || 0) + n);
|
|
980
|
-
if (ops?.mul) for (const [col, n] of Object.entries(ops.mul)) setPath(row, col, (Number(getPath(row, col)) || 0) * n);
|
|
945
|
+
if (ops?.inc) for (const [col, n] of Object.entries(ops.inc)) setPath(row, col, (Number(getPath$1(row, col)) || 0) + n);
|
|
946
|
+
if (ops?.mul) for (const [col, n] of Object.entries(ops.mul)) setPath(row, col, (Number(getPath$1(row, col)) || 0) * n);
|
|
981
947
|
}
|
|
982
948
|
/**
|
|
983
949
|
* Places `next` into the store under its (possibly changed) {@link pkKey},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.141",
|
|
4
4
|
"description": "In-memory adapter for atscript-db.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@atscript/core": "^0.1.
|
|
40
|
-
"@atscript/typescript": "^0.1.
|
|
39
|
+
"@atscript/core": "^0.1.95",
|
|
40
|
+
"@atscript/typescript": "^0.1.95",
|
|
41
41
|
"@uniqu/core": "^0.1.11",
|
|
42
|
-
"unplugin-atscript": "^0.1.
|
|
42
|
+
"unplugin-atscript": "^0.1.95"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@atscript/core": "^0.1.
|
|
46
|
-
"@atscript/typescript": "^0.1.
|
|
45
|
+
"@atscript/core": "^0.1.95",
|
|
46
|
+
"@atscript/typescript": "^0.1.95",
|
|
47
47
|
"@uniqu/core": "^0.1.11",
|
|
48
|
-
"@atscript/db": "^0.1.
|
|
48
|
+
"@atscript/db": "^0.1.141"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"postinstall": "asc -f dts",
|