@signaldb/core 2.0.0-beta.13 → 2.0.0-beta.14

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.
Files changed (82) hide show
  1. package/dist/.vite/manifest.json +72 -46
  2. package/dist/AsyncDataAdapter.d.ts +11 -2
  3. package/dist/Collection/Cursor.d.ts +11 -1
  4. package/dist/Collection/Observer.d.ts +31 -0
  5. package/dist/DataAdapter.d.ts +15 -2
  6. package/dist/WorkerDataAdapter.d.ts +25 -2
  7. package/dist/WorkerDataAdapterHost.d.ts +2 -0
  8. package/dist/index.cjs.js +15 -15
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.mjs +15 -15
  11. package/dist/index10.cjs.js +7 -19
  12. package/dist/index10.mjs +7 -19
  13. package/dist/index11.cjs.js +19 -41
  14. package/dist/index11.mjs +19 -41
  15. package/dist/index12.cjs.js +41 -18
  16. package/dist/index12.mjs +41 -18
  17. package/dist/index13.cjs.js +18 -41
  18. package/dist/index13.mjs +18 -41
  19. package/dist/index14.cjs.js +39 -80
  20. package/dist/index14.mjs +39 -80
  21. package/dist/index15.cjs.js +82 -11
  22. package/dist/index15.mjs +82 -11
  23. package/dist/index16.cjs.js +11 -132
  24. package/dist/index16.mjs +11 -132
  25. package/dist/index17.cjs.js +127 -38
  26. package/dist/index17.mjs +127 -38
  27. package/dist/index18.cjs.js +43 -11
  28. package/dist/index18.mjs +43 -11
  29. package/dist/index19.cjs.js +10 -18
  30. package/dist/index19.mjs +11 -19
  31. package/dist/index20.cjs.js +19 -33
  32. package/dist/index20.mjs +19 -33
  33. package/dist/index21.cjs.js +33 -31
  34. package/dist/index21.mjs +33 -31
  35. package/dist/index22.cjs.js +31 -21
  36. package/dist/index22.mjs +31 -21
  37. package/dist/index23.cjs.js +16 -14
  38. package/dist/index23.mjs +16 -14
  39. package/dist/index24.cjs.js +15 -338
  40. package/dist/index24.mjs +15 -338
  41. package/dist/index25.cjs.js +122 -554
  42. package/dist/index25.mjs +121 -554
  43. package/dist/index26.cjs.js +34 -7
  44. package/dist/index26.mjs +34 -7
  45. package/dist/index27.cjs.js +339 -7
  46. package/dist/index27.mjs +339 -7
  47. package/dist/index28.cjs.js +550 -83
  48. package/dist/index28.mjs +550 -82
  49. package/dist/index29.cjs.js +8 -422
  50. package/dist/index29.mjs +8 -422
  51. package/dist/index30.cjs.js +7 -68
  52. package/dist/index30.mjs +7 -68
  53. package/dist/index31.cjs.js +86 -28
  54. package/dist/index31.mjs +85 -28
  55. package/dist/index32.cjs.js +446 -278
  56. package/dist/index32.mjs +446 -278
  57. package/dist/index33.cjs.js +68 -17
  58. package/dist/index33.mjs +68 -17
  59. package/dist/index34.cjs.js +460 -304
  60. package/dist/index34.mjs +460 -304
  61. package/dist/index35.cjs.js +14 -532
  62. package/dist/index35.mjs +14 -532
  63. package/dist/index36.cjs.js +389 -0
  64. package/dist/index36.mjs +389 -0
  65. package/dist/index37.cjs.js +539 -0
  66. package/dist/index37.mjs +539 -0
  67. package/dist/index4.cjs.js +199 -140
  68. package/dist/index4.mjs +195 -140
  69. package/dist/index5.cjs.js +152 -253
  70. package/dist/index5.mjs +152 -253
  71. package/dist/index6.cjs.js +267 -89
  72. package/dist/index6.mjs +267 -89
  73. package/dist/index7.cjs.js +121 -29
  74. package/dist/index7.mjs +121 -29
  75. package/dist/index8.cjs.js +29 -8
  76. package/dist/index8.mjs +29 -8
  77. package/dist/index9.cjs.js +8 -7
  78. package/dist/index9.mjs +8 -7
  79. package/dist/utils/incrementalQueryUpdate.d.ts +60 -0
  80. package/dist/utils/projectItems.d.ts +12 -0
  81. package/dist/utils/queryDelta.d.ts +83 -0
  82. package/package.json +1 -1
package/dist/index10.mjs CHANGED
@@ -1,23 +1,11 @@
1
- //#region src/utils/get.ts
1
+ //#region src/createIndexProvider.ts
2
2
  /**
3
- * Retrieves the value at a specified path within an object.
4
- * Supports dot and bracket notation for navigating nested properties.
5
- * @template T - The type of the object to retrieve the value from.
6
- * @param value - The object to navigate.
7
- * @param path - The path (dot or bracket notation) to the desired value.
8
- * @returns The value at the specified path, or `undefined` if the path does not exist.
3
+ * Creates an IndexProvider based on the given definition.
4
+ * @param definition - The definition of the IndexProvider.
5
+ * @returns The created IndexProvider.
9
6
  */
10
- function get(value, path) {
11
- const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
12
- if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) return;
13
- const segments = normalized.split(".");
14
- let current = value;
15
- for (const key of segments) {
16
- if (current == null) return;
17
- current = current[key];
18
- }
19
- if (current === void 0) return;
20
- return current;
7
+ function createIndexProvider(definition) {
8
+ return definition;
21
9
  }
22
10
  //#endregion
23
- export { get as default };
11
+ export { createIndexProvider as default };
@@ -1,45 +1,23 @@
1
- //#region src/utils/isFieldExpression.ts
2
- var expressionKeys = new Set([
3
- "$eq",
4
- "$gt",
5
- "$gte",
6
- "$lt",
7
- "$lte",
8
- "$in",
9
- "$nin",
10
- "$ne",
11
- "$exists",
12
- "$not",
13
- "$expr",
14
- "$jsonSchema",
15
- "$mod",
16
- "$regex",
17
- "$options",
18
- "$text",
19
- "$where",
20
- "$all",
21
- "$elemMatch",
22
- "$size",
23
- "$bitsAllClear",
24
- "$bitsAllSet",
25
- "$bitsAnyClear",
26
- "$bitsAnySet"
27
- ]);
1
+ //#region src/utils/get.ts
28
2
  /**
29
- * Determines whether a given object is a valid field expression.
30
- * A field expression is an object containing query operators supported by MongoDB-style queries.
31
- * @template T - The type of the field expression.
32
- * @param expression - The object to test.
33
- * @returns A boolean indicating whether the object is a valid field expression.
34
- * - `true` if the object contains only recognized query operators.
35
- * - `false` otherwise.
3
+ * Retrieves the value at a specified path within an object.
4
+ * Supports dot and bracket notation for navigating nested properties.
5
+ * @template T - The type of the object to retrieve the value from.
6
+ * @param value - The object to navigate.
7
+ * @param path - The path (dot or bracket notation) to the desired value.
8
+ * @returns The value at the specified path, or `undefined` if the path does not exist.
36
9
  */
37
- function isFieldExpression(expression) {
38
- if (typeof expression !== "object" || expression == null) return false;
39
- const keys = Object.keys(expression);
40
- if (keys.length === 0) return false;
41
- if (keys.some((key) => !expressionKeys.has(key))) return false;
42
- return keys.every((key) => expressionKeys.has(key));
10
+ function get(value, path) {
11
+ const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
12
+ if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) return;
13
+ const segments = normalized.split(".");
14
+ let current = value;
15
+ for (const key of segments) {
16
+ if (current == null) return;
17
+ current = current[key];
18
+ }
19
+ if (current === void 0) return;
20
+ return current;
43
21
  }
44
22
  //#endregion
45
- exports.default = isFieldExpression;
23
+ exports.default = get;
package/dist/index11.mjs CHANGED
@@ -1,45 +1,23 @@
1
- //#region src/utils/isFieldExpression.ts
2
- var expressionKeys = new Set([
3
- "$eq",
4
- "$gt",
5
- "$gte",
6
- "$lt",
7
- "$lte",
8
- "$in",
9
- "$nin",
10
- "$ne",
11
- "$exists",
12
- "$not",
13
- "$expr",
14
- "$jsonSchema",
15
- "$mod",
16
- "$regex",
17
- "$options",
18
- "$text",
19
- "$where",
20
- "$all",
21
- "$elemMatch",
22
- "$size",
23
- "$bitsAllClear",
24
- "$bitsAllSet",
25
- "$bitsAnyClear",
26
- "$bitsAnySet"
27
- ]);
1
+ //#region src/utils/get.ts
28
2
  /**
29
- * Determines whether a given object is a valid field expression.
30
- * A field expression is an object containing query operators supported by MongoDB-style queries.
31
- * @template T - The type of the field expression.
32
- * @param expression - The object to test.
33
- * @returns A boolean indicating whether the object is a valid field expression.
34
- * - `true` if the object contains only recognized query operators.
35
- * - `false` otherwise.
3
+ * Retrieves the value at a specified path within an object.
4
+ * Supports dot and bracket notation for navigating nested properties.
5
+ * @template T - The type of the object to retrieve the value from.
6
+ * @param value - The object to navigate.
7
+ * @param path - The path (dot or bracket notation) to the desired value.
8
+ * @returns The value at the specified path, or `undefined` if the path does not exist.
36
9
  */
37
- function isFieldExpression(expression) {
38
- if (typeof expression !== "object" || expression == null) return false;
39
- const keys = Object.keys(expression);
40
- if (keys.length === 0) return false;
41
- if (keys.some((key) => !expressionKeys.has(key))) return false;
42
- return keys.every((key) => expressionKeys.has(key));
10
+ function get(value, path) {
11
+ const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
12
+ if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) return;
13
+ const segments = normalized.split(".");
14
+ let current = value;
15
+ for (const key of segments) {
16
+ if (current == null) return;
17
+ current = current[key];
18
+ }
19
+ if (current === void 0) return;
20
+ return current;
43
21
  }
44
22
  //#endregion
45
- export { isFieldExpression as default };
23
+ export { get as default };
@@ -1,22 +1,45 @@
1
- //#region src/utils/serializeValue.ts
1
+ //#region src/utils/isFieldExpression.ts
2
+ var expressionKeys = new Set([
3
+ "$eq",
4
+ "$gt",
5
+ "$gte",
6
+ "$lt",
7
+ "$lte",
8
+ "$in",
9
+ "$nin",
10
+ "$ne",
11
+ "$exists",
12
+ "$not",
13
+ "$expr",
14
+ "$jsonSchema",
15
+ "$mod",
16
+ "$regex",
17
+ "$options",
18
+ "$text",
19
+ "$where",
20
+ "$all",
21
+ "$elemMatch",
22
+ "$size",
23
+ "$bitsAllClear",
24
+ "$bitsAllSet",
25
+ "$bitsAnyClear",
26
+ "$bitsAnySet"
27
+ ]);
2
28
  /**
3
- * Serializes a value into a string representation.
4
- * Handles various types, including strings, numbers, booleans, dates, and objects.
5
- * Falls back to JSON stringification for unsupported types.
6
- * @param value - The value to serialize.
7
- * - Strings are returned as-is.
8
- * - Numbers and booleans are converted to their string representation.
9
- * - Dates are converted to ISO string format.
10
- * - Other values are stringified using `JSON.stringify`.
11
- * @returns A string representation of the value.
29
+ * Determines whether a given object is a valid field expression.
30
+ * A field expression is an object containing query operators supported by MongoDB-style queries.
31
+ * @template T - The type of the field expression.
32
+ * @param expression - The object to test.
33
+ * @returns A boolean indicating whether the object is a valid field expression.
34
+ * - `true` if the object contains only recognized query operators.
35
+ * - `false` otherwise.
12
36
  */
13
- function serializeValue(value) {
14
- if (value == null) return null;
15
- if (typeof value === "string") return value;
16
- if (typeof value === "number") return value.toString();
17
- if (typeof value === "boolean") return value.toString();
18
- if (value instanceof Date) return value.toISOString();
19
- return JSON.stringify(value);
37
+ function isFieldExpression(expression) {
38
+ if (typeof expression !== "object" || expression == null) return false;
39
+ const keys = Object.keys(expression);
40
+ if (keys.length === 0) return false;
41
+ if (keys.some((key) => !expressionKeys.has(key))) return false;
42
+ return keys.every((key) => expressionKeys.has(key));
20
43
  }
21
44
  //#endregion
22
- exports.default = serializeValue;
45
+ exports.default = isFieldExpression;
package/dist/index12.mjs CHANGED
@@ -1,22 +1,45 @@
1
- //#region src/utils/serializeValue.ts
1
+ //#region src/utils/isFieldExpression.ts
2
+ var expressionKeys = new Set([
3
+ "$eq",
4
+ "$gt",
5
+ "$gte",
6
+ "$lt",
7
+ "$lte",
8
+ "$in",
9
+ "$nin",
10
+ "$ne",
11
+ "$exists",
12
+ "$not",
13
+ "$expr",
14
+ "$jsonSchema",
15
+ "$mod",
16
+ "$regex",
17
+ "$options",
18
+ "$text",
19
+ "$where",
20
+ "$all",
21
+ "$elemMatch",
22
+ "$size",
23
+ "$bitsAllClear",
24
+ "$bitsAllSet",
25
+ "$bitsAnyClear",
26
+ "$bitsAnySet"
27
+ ]);
2
28
  /**
3
- * Serializes a value into a string representation.
4
- * Handles various types, including strings, numbers, booleans, dates, and objects.
5
- * Falls back to JSON stringification for unsupported types.
6
- * @param value - The value to serialize.
7
- * - Strings are returned as-is.
8
- * - Numbers and booleans are converted to their string representation.
9
- * - Dates are converted to ISO string format.
10
- * - Other values are stringified using `JSON.stringify`.
11
- * @returns A string representation of the value.
29
+ * Determines whether a given object is a valid field expression.
30
+ * A field expression is an object containing query operators supported by MongoDB-style queries.
31
+ * @template T - The type of the field expression.
32
+ * @param expression - The object to test.
33
+ * @returns A boolean indicating whether the object is a valid field expression.
34
+ * - `true` if the object contains only recognized query operators.
35
+ * - `false` otherwise.
12
36
  */
13
- function serializeValue(value) {
14
- if (value == null) return null;
15
- if (typeof value === "string") return value;
16
- if (typeof value === "number") return value.toString();
17
- if (typeof value === "boolean") return value.toString();
18
- if (value instanceof Date) return value.toISOString();
19
- return JSON.stringify(value);
37
+ function isFieldExpression(expression) {
38
+ if (typeof expression !== "object" || expression == null) return false;
39
+ const keys = Object.keys(expression);
40
+ if (keys.length === 0) return false;
41
+ if (keys.some((key) => !expressionKeys.has(key))) return false;
42
+ return keys.every((key) => expressionKeys.has(key));
20
43
  }
21
44
  //#endregion
22
- export { serializeValue as default };
45
+ export { isFieldExpression as default };
@@ -1,45 +1,22 @@
1
- const require_isFieldExpression = require("./index11.cjs.js");
2
- const require_serializeValue = require("./index12.cjs.js");
3
- //#region src/utils/getMatchingKeys.ts
1
+ //#region src/utils/serializeValue.ts
4
2
  /**
5
- * Extracts the matching and excluded keys for a given field in a selector.
6
- * Supports serialized values and `$in`/`$nin` field expressions for optimization.
7
- * Returns `null` for include/exclude if the field cannot be optimized.
8
- * @template T - The type of the items in the selector.
9
- * @template I - The type of the unique identifier for the items.
10
- * @param field - The name of the field to extract matching keys for.
11
- * @param selector - The selector object containing query criteria.
12
- * @returns An object containing arrays of serialized included and excluded keys,
13
- * or `null` if the field cannot be optimized.
3
+ * Serializes a value into a string representation.
4
+ * Handles various types, including strings, numbers, booleans, dates, and objects.
5
+ * Falls back to JSON stringification for unsupported types.
6
+ * @param value - The value to serialize.
7
+ * - Strings are returned as-is.
8
+ * - Numbers and booleans are converted to their string representation.
9
+ * - Dates are converted to ISO string format.
10
+ * - Other values are stringified using `JSON.stringify`.
11
+ * @returns A string representation of the value.
14
12
  */
15
- function getMatchingKeys(field, selector) {
16
- const result = {
17
- include: null,
18
- exclude: null
19
- };
20
- const fieldSelector = selector[field];
21
- if (fieldSelector instanceof RegExp) return result;
22
- if (fieldSelector == null) return result;
23
- if (require_isFieldExpression.default(fieldSelector)) {
24
- if (fieldSelector.$ne != null) {
25
- result.exclude = [require_serializeValue.default(fieldSelector.$ne)];
26
- return result;
27
- }
28
- if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
29
- result.include = fieldSelector.$in.map(require_serializeValue.default);
30
- return result;
31
- }
32
- if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
33
- result.exclude = fieldSelector.$nin.map(require_serializeValue.default);
34
- return result;
35
- }
36
- return {
37
- include: null,
38
- exclude: null
39
- };
40
- }
41
- result.include = [require_serializeValue.default(fieldSelector)];
42
- return result;
13
+ function serializeValue(value) {
14
+ if (value == null) return null;
15
+ if (typeof value === "string") return value;
16
+ if (typeof value === "number") return value.toString();
17
+ if (typeof value === "boolean") return value.toString();
18
+ if (value instanceof Date) return value.toISOString();
19
+ return JSON.stringify(value);
43
20
  }
44
21
  //#endregion
45
- exports.default = getMatchingKeys;
22
+ exports.default = serializeValue;
package/dist/index13.mjs CHANGED
@@ -1,45 +1,22 @@
1
- import isFieldExpression from "./index11.mjs";
2
- import serializeValue from "./index12.mjs";
3
- //#region src/utils/getMatchingKeys.ts
1
+ //#region src/utils/serializeValue.ts
4
2
  /**
5
- * Extracts the matching and excluded keys for a given field in a selector.
6
- * Supports serialized values and `$in`/`$nin` field expressions for optimization.
7
- * Returns `null` for include/exclude if the field cannot be optimized.
8
- * @template T - The type of the items in the selector.
9
- * @template I - The type of the unique identifier for the items.
10
- * @param field - The name of the field to extract matching keys for.
11
- * @param selector - The selector object containing query criteria.
12
- * @returns An object containing arrays of serialized included and excluded keys,
13
- * or `null` if the field cannot be optimized.
3
+ * Serializes a value into a string representation.
4
+ * Handles various types, including strings, numbers, booleans, dates, and objects.
5
+ * Falls back to JSON stringification for unsupported types.
6
+ * @param value - The value to serialize.
7
+ * - Strings are returned as-is.
8
+ * - Numbers and booleans are converted to their string representation.
9
+ * - Dates are converted to ISO string format.
10
+ * - Other values are stringified using `JSON.stringify`.
11
+ * @returns A string representation of the value.
14
12
  */
15
- function getMatchingKeys(field, selector) {
16
- const result = {
17
- include: null,
18
- exclude: null
19
- };
20
- const fieldSelector = selector[field];
21
- if (fieldSelector instanceof RegExp) return result;
22
- if (fieldSelector == null) return result;
23
- if (isFieldExpression(fieldSelector)) {
24
- if (fieldSelector.$ne != null) {
25
- result.exclude = [serializeValue(fieldSelector.$ne)];
26
- return result;
27
- }
28
- if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
29
- result.include = fieldSelector.$in.map(serializeValue);
30
- return result;
31
- }
32
- if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
33
- result.exclude = fieldSelector.$nin.map(serializeValue);
34
- return result;
35
- }
36
- return {
37
- include: null,
38
- exclude: null
39
- };
40
- }
41
- result.include = [serializeValue(fieldSelector)];
42
- return result;
13
+ function serializeValue(value) {
14
+ if (value == null) return null;
15
+ if (typeof value === "string") return value;
16
+ if (typeof value === "number") return value.toString();
17
+ if (typeof value === "boolean") return value.toString();
18
+ if (value instanceof Date) return value.toISOString();
19
+ return JSON.stringify(value);
43
20
  }
44
21
  //#endregion
45
- export { getMatchingKeys as default };
22
+ export { serializeValue as default };
@@ -1,86 +1,45 @@
1
- const require_createIndexProvider = require("./index9.cjs.js");
2
- const require_get = require("./index10.cjs.js");
3
- const require_serializeValue = require("./index12.cjs.js");
4
- const require_getMatchingKeys = require("./index13.cjs.js");
5
- //#region src/createIndex.ts
1
+ const require_isFieldExpression = require("./index12.cjs.js");
2
+ const require_serializeValue = require("./index13.cjs.js");
3
+ //#region src/utils/getMatchingKeys.ts
6
4
  /**
7
- * creates an index for a specific field
8
- * @param field name of the field
9
- * @returns an index provider to pass to the `indices` option of the collection constructor
5
+ * Extracts the matching and excluded keys for a given field in a selector.
6
+ * Supports serialized values and `$in`/`$nin` field expressions for optimization.
7
+ * Returns `null` for include/exclude if the field cannot be optimized.
8
+ * @template T - The type of the items in the selector.
9
+ * @template I - The type of the unique identifier for the items.
10
+ * @param field - The name of the field to extract matching keys for.
11
+ * @param selector - The selector object containing query criteria.
12
+ * @returns An object containing arrays of serialized included and excluded keys,
13
+ * or `null` if the field cannot be optimized.
10
14
  */
11
- function createIndex(field) {
12
- const index = /* @__PURE__ */ new Map();
13
- const ensureSet = (key) => {
14
- let set = index.get(key);
15
- if (!set) {
16
- set = /* @__PURE__ */ new Set();
17
- index.set(key, set);
18
- }
19
- return set;
15
+ function getMatchingKeys(field, selector) {
16
+ const result = {
17
+ include: null,
18
+ exclude: null
20
19
  };
21
- return require_createIndexProvider.default({
22
- query(selector) {
23
- if (!Object.hasOwnProperty.call(selector, field)) return { matched: false };
24
- const fieldSelector = selector[field];
25
- const filteresForNull = fieldSelector == null || fieldSelector.$exists === false;
26
- const keys = filteresForNull ? {
27
- include: null,
28
- exclude: [...index.keys()].filter((key) => key != null)
29
- } : require_getMatchingKeys.default(field, selector);
30
- if (keys.include == null && keys.exclude == null) return { matched: false };
31
- let includedIds = [];
32
- if (keys.include == null) for (const set of index.values()) for (const pos of set) includedIds.push(pos);
33
- else for (const key of keys.include) {
34
- const posSet = index.get(key);
35
- if (posSet) for (const pos of posSet) includedIds.push(pos);
36
- }
37
- if (keys.exclude != null) {
38
- const excludeIds = /* @__PURE__ */ new Set();
39
- for (const key of keys.exclude) {
40
- const posSet = index.get(key);
41
- if (posSet) for (const pos of posSet) excludeIds.add(pos);
42
- }
43
- includedIds = includedIds.filter((pos) => !excludeIds.has(pos));
44
- }
45
- return {
46
- matched: true,
47
- ids: includedIds,
48
- fields: [field],
49
- keepSelector: filteresForNull
50
- };
51
- },
52
- rebuild(items) {
53
- index.clear();
54
- items.forEach((item) => {
55
- ensureSet(require_serializeValue.default(require_get.default(item, field))).add(item.id);
56
- });
57
- },
58
- insert(items) {
59
- for (const item of items) ensureSet(require_serializeValue.default(require_get.default(item, field))).add(item.id);
60
- },
61
- remove(items) {
62
- for (const item of items) {
63
- const value = require_serializeValue.default(require_get.default(item, field));
64
- const set = index.get(value);
65
- if (!set) continue;
66
- set.delete(item.id);
67
- if (set.size === 0) index.delete(value);
68
- }
69
- },
70
- update(pairs) {
71
- for (const { oldItem, newItem } of pairs) {
72
- const oldValue = require_serializeValue.default(require_get.default(oldItem, field));
73
- const newValue = require_serializeValue.default(require_get.default(newItem, field));
74
- if (oldValue === newValue) continue;
75
- const oldSet = index.get(oldValue);
76
- if (oldSet) {
77
- oldSet.delete(oldItem.id);
78
- if (oldSet.size === 0) index.delete(oldValue);
79
- }
80
- ensureSet(newValue).add(newItem.id);
81
- }
20
+ const fieldSelector = selector[field];
21
+ if (fieldSelector instanceof RegExp) return result;
22
+ if (fieldSelector == null) return result;
23
+ if (require_isFieldExpression.default(fieldSelector)) {
24
+ if (fieldSelector.$ne != null) {
25
+ result.exclude = [require_serializeValue.default(fieldSelector.$ne)];
26
+ return result;
27
+ }
28
+ if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
29
+ result.include = fieldSelector.$in.map(require_serializeValue.default);
30
+ return result;
31
+ }
32
+ if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
33
+ result.exclude = fieldSelector.$nin.map(require_serializeValue.default);
34
+ return result;
82
35
  }
83
- });
36
+ return {
37
+ include: null,
38
+ exclude: null
39
+ };
40
+ }
41
+ result.include = [require_serializeValue.default(fieldSelector)];
42
+ return result;
84
43
  }
85
44
  //#endregion
86
- exports.default = createIndex;
45
+ exports.default = getMatchingKeys;