inibase 1.1.26 → 1.1.28
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 +9 -7
- 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,20 +890,18 @@ 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
|
-
? Array.from(searchableIDs.values()).flat()
|
|
894
|
-
: searchableIDs.values())).flat(), {
|
|
893
|
+
const items = await this.get(field.table, Array.from(new Set(Array.from(searchableIDs.values()).flat())).flat(), {
|
|
895
894
|
...options,
|
|
896
895
|
perPage: Number.POSITIVE_INFINITY,
|
|
897
896
|
columns: options.columns
|
|
898
897
|
?.filter((column) => column.includes(`${field.key}.`))
|
|
899
898
|
.map((column) => column.replace(`${field.key}.`, "")),
|
|
900
899
|
});
|
|
901
|
-
for (const [lineNumber, lineContent] of searchableIDs.entries())
|
|
902
|
-
RETURN[lineNumber][field.key] =
|
|
900
|
+
for (const [lineNumber, lineContent] of searchableIDs.entries()) {
|
|
901
|
+
RETURN[lineNumber][field.key] = Array.isArray(lineContent)
|
|
903
902
|
? Utils.isArrayOfArrays(lineContent)
|
|
904
903
|
? lineContent.map((item) => items
|
|
905
|
-
? items.
|
|
904
|
+
? items.find(({ id }) => item === id)
|
|
906
905
|
: {
|
|
907
906
|
id: item,
|
|
908
907
|
})
|
|
@@ -912,6 +911,7 @@ export default class Inibase {
|
|
|
912
911
|
: (items?.find(({ id }) => id === lineContent) ?? {
|
|
913
912
|
id: lineContent,
|
|
914
913
|
});
|
|
914
|
+
}
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
917
|
}
|
|
@@ -1046,6 +1046,8 @@ export default class Inibase {
|
|
|
1046
1046
|
if (!Object.keys(RETURN).length)
|
|
1047
1047
|
RETURN = {};
|
|
1048
1048
|
}
|
|
1049
|
+
else
|
|
1050
|
+
RETURN = {};
|
|
1049
1051
|
}
|
|
1050
1052
|
return Object.keys(RETURN).length ? RETURN : null;
|
|
1051
1053
|
}
|