inibase 1.1.18 → 1.1.19
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.js +3 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +25 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -947,6 +947,7 @@ export default class Inibase {
|
|
|
947
947
|
if (Object.keys(criteria).length > 0) {
|
|
948
948
|
if (allTrue === undefined)
|
|
949
949
|
allTrue = true;
|
|
950
|
+
criteria = Utils.toDotNotation(criteria, ["or", "and"]);
|
|
950
951
|
let index = -1;
|
|
951
952
|
for await (const [key, value] of Object.entries(criteria)) {
|
|
952
953
|
const field = Utils.getField(key, this.tablesMap.get(tableName).schema);
|
|
@@ -1038,7 +1039,8 @@ export default class Inibase {
|
|
|
1038
1039
|
RETURN = Utils.deepMerge(RETURN, searchResult);
|
|
1039
1040
|
if (!Object.keys(RETURN).length)
|
|
1040
1041
|
RETURN = {};
|
|
1041
|
-
RETURN = Object.fromEntries(Object.entries(RETURN).filter(([_index, item]) => Object.keys(item).filter((key) => Object.keys(criteriaOR).includes(key)
|
|
1042
|
+
RETURN = Object.fromEntries(Object.entries(RETURN).filter(([_index, item]) => Object.keys(item).filter((key) => Object.keys(criteriaOR).includes(key) ||
|
|
1043
|
+
Object.keys(criteriaOR).some((criteriaKey) => criteriaKey.startsWith(`${key}.`))).length));
|
|
1042
1044
|
if (!Object.keys(RETURN).length)
|
|
1043
1045
|
RETURN = {};
|
|
1044
1046
|
searchIn = lineNumbers;
|
package/dist/utils.d.ts
CHANGED
|
@@ -200,3 +200,4 @@ export declare const setField: (keyPath: string, schema: Schema, field: Omit<Fie
|
|
|
200
200
|
* @param {Schema} schema
|
|
201
201
|
*/
|
|
202
202
|
export declare const unsetField: (keyPath: string, schema: Schema) => Field;
|
|
203
|
+
export declare function toDotNotation(obj: Record<string, any>, skipKeys?: string[], currentPath?: string): Record<string, any>;
|
package/dist/utils.js
CHANGED
|
@@ -554,3 +554,28 @@ export const unsetField = (keyPath, schema) => {
|
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
};
|
|
557
|
+
export function toDotNotation(obj, skipKeys, currentPath = "") {
|
|
558
|
+
const result = {};
|
|
559
|
+
for (const key in obj) {
|
|
560
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
561
|
+
const value = obj[key];
|
|
562
|
+
const newKey = currentPath ? `${currentPath}.${key}` : key;
|
|
563
|
+
if (skipKeys?.includes(key.toLowerCase())) {
|
|
564
|
+
// Preserve "or" and "and" keys with their exact values
|
|
565
|
+
result[newKey] = value;
|
|
566
|
+
}
|
|
567
|
+
else if (typeof value === "object" &&
|
|
568
|
+
value !== null &&
|
|
569
|
+
!Array.isArray(value)) {
|
|
570
|
+
// Recursively process nested objects
|
|
571
|
+
const nested = toDotNotation(value, skipKeys, newKey);
|
|
572
|
+
Object.assign(result, nested);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
// Add primitive values directly
|
|
576
|
+
result[newKey] = value;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
}
|