inibase 1.1.27 → 1.1.29
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/file.js +3 -3
- package/dist/index.js +24 -17
- package/package.json +1 -1
package/dist/file.js
CHANGED
|
@@ -159,9 +159,9 @@ const decodeHelper = (value, field) => {
|
|
|
159
159
|
return isNumber(value) &&
|
|
160
160
|
(!field.table ||
|
|
161
161
|
!field.databasePath ||
|
|
162
|
-
field.
|
|
163
|
-
|
|
164
|
-
.
|
|
162
|
+
(!globalConfig[field.databasePath].tables?.get(field.table)?.config
|
|
163
|
+
.decodeID &&
|
|
164
|
+
field.key !== "id"))
|
|
165
165
|
? encodeID(value)
|
|
166
166
|
: value;
|
|
167
167
|
default:
|
package/dist/index.js
CHANGED
|
@@ -873,11 +873,12 @@ export default class Inibase {
|
|
|
873
873
|
(await File.isExists(join(this.databasePath, field.table)))) {
|
|
874
874
|
const fieldPath = join(this.databasePath, tableName, `${prefix ?? ""}${field.key}${this.getFileExtension(tableName)}`);
|
|
875
875
|
if (await File.isExists(fieldPath)) {
|
|
876
|
+
// add table to globalConfig
|
|
877
|
+
await this.getTable(field.table);
|
|
876
878
|
const itemsIDs = (await File.get(fieldPath, linesNumber, {
|
|
877
879
|
...field,
|
|
878
880
|
databasePath: this.databasePath,
|
|
879
881
|
}));
|
|
880
|
-
const isArrayField = this.isArrayField(field.type);
|
|
881
882
|
if (itemsIDs) {
|
|
882
883
|
const searchableIDs = new Map();
|
|
883
884
|
for (const [lineNumber, lineContent] of Object.entries(itemsIDs)) {
|
|
@@ -889,29 +890,33 @@ export default class Inibase {
|
|
|
889
890
|
searchableIDs.set(lineNumber, lineContent);
|
|
890
891
|
}
|
|
891
892
|
if (searchableIDs.size) {
|
|
892
|
-
const items = await this.get(field.table, Array.from(new Set(
|
|
893
|
-
|
|
894
|
-
|
|
893
|
+
const items = await this.get(field.table, Array.from(new Set(Array.from(searchableIDs.values()).flat()))
|
|
894
|
+
.flat()
|
|
895
|
+
.filter((item) => item), {
|
|
895
896
|
...options,
|
|
896
897
|
perPage: Number.POSITIVE_INFINITY,
|
|
897
898
|
columns: options.columns
|
|
898
899
|
?.filter((column) => column.includes(`${field.key}.`))
|
|
899
900
|
.map((column) => column.replace(`${field.key}.`, "")),
|
|
900
901
|
});
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
?
|
|
904
|
-
?
|
|
905
|
-
|
|
902
|
+
const formatLineContent = (lineContent) => Array.isArray(lineContent)
|
|
903
|
+
? lineContent.map((singleContent) => singleContent
|
|
904
|
+
? Array.isArray(singleContent)
|
|
905
|
+
? singleContent.map(formatLineContent)
|
|
906
|
+
: items
|
|
907
|
+
? items.find(({ id }) => singleContent === id)
|
|
906
908
|
: {
|
|
907
|
-
id:
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
909
|
+
id: singleContent,
|
|
910
|
+
}
|
|
911
|
+
: singleContent)
|
|
912
|
+
: (items?.find(({ id }) => lineContent === id) ?? {
|
|
913
|
+
id: lineContent,
|
|
914
|
+
});
|
|
915
|
+
for (const [lineNumber, lineContent] of searchableIDs.entries()) {
|
|
916
|
+
if (!lineContent)
|
|
917
|
+
continue;
|
|
918
|
+
RETURN[lineNumber][field.key] = formatLineContent(lineContent);
|
|
919
|
+
}
|
|
915
920
|
}
|
|
916
921
|
}
|
|
917
922
|
}
|
|
@@ -948,6 +953,8 @@ export default class Inibase {
|
|
|
948
953
|
let index = -1;
|
|
949
954
|
for await (const [key, value] of Object.entries(criteria)) {
|
|
950
955
|
const field = Utils.getField(key, globalConfig[this.databasePath].tables.get(tableName).schema);
|
|
956
|
+
if (!field)
|
|
957
|
+
continue;
|
|
951
958
|
index++;
|
|
952
959
|
let searchOperator = undefined;
|
|
953
960
|
let searchComparedAtValue = undefined;
|