inibase 1.1.11 → 1.1.12
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/cli.js +1 -1
- package/dist/index.js +15 -6
- package/dist/utils.server.js +3 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -102,7 +102,7 @@ rl.on("line", async (input) => {
|
|
|
102
102
|
const configName = splitedInput[index].toLocaleLowerCase();
|
|
103
103
|
if (["true", "false"].includes(configName))
|
|
104
104
|
continue;
|
|
105
|
-
if (!["compression", "cache", "prepend"].includes(configName)) {
|
|
105
|
+
if (!["compression", "cache", "prepend", "decodeID"].includes(configName)) {
|
|
106
106
|
console.log(`${textRed(" Err:")} '${configName}' is not a valid config`);
|
|
107
107
|
break;
|
|
108
108
|
}
|
package/dist/index.js
CHANGED
|
@@ -1002,7 +1002,9 @@ export default class Inibase {
|
|
|
1002
1002
|
searchOperator = "=";
|
|
1003
1003
|
searchComparedAtValue = value;
|
|
1004
1004
|
}
|
|
1005
|
-
const [searchResult, totalLines, linesNumbers] = await File.search(join(tablePath, `${key}${this.getFileExtension(tableName)}`), searchOperator ?? "=", searchComparedAtValue ?? null, searchLogicalOperator, allTrue ? searchIn : undefined, field?.type, field?.children, options.perPage, (options.page - 1) * options.perPage + 1, true, this.
|
|
1005
|
+
const [searchResult, totalLines, linesNumbers] = await File.search(join(tablePath, `${key}${this.getFileExtension(tableName)}`), searchOperator ?? "=", searchComparedAtValue ?? null, searchLogicalOperator, allTrue ? searchIn : undefined, field?.type, field?.children, options.perPage, (options.page - 1) * options.perPage + 1, true, field.key === "id" && this.tablesMap.get(tableName).config.decodeID
|
|
1006
|
+
? undefined
|
|
1007
|
+
: this.salt);
|
|
1006
1008
|
if (searchResult) {
|
|
1007
1009
|
const formatedSearchResult = Object.fromEntries(Object.entries(searchResult).map(([id, value]) => {
|
|
1008
1010
|
const nestedObj = {};
|
|
@@ -1133,14 +1135,16 @@ export default class Inibase {
|
|
|
1133
1135
|
1)
|
|
1134
1136
|
.map((lineNumber) => `NR==${lineNumber}`)
|
|
1135
1137
|
.join(" || ")}'`;
|
|
1136
|
-
const filesPathes =
|
|
1138
|
+
const filesPathes = (sortArray.find(([key]) => key === "id")
|
|
1139
|
+
? sortArray
|
|
1140
|
+
: [["id", true], ...sortArray]).map((column) => join(tablePath, `${column[0]}${this.getFileExtension(tableName)}`));
|
|
1137
1141
|
for await (const path of filesPathes.slice(1))
|
|
1138
1142
|
if (!(await File.isExists(path)))
|
|
1139
1143
|
return null;
|
|
1140
1144
|
// Construct the paste command to merge files and filter lines by IDs
|
|
1141
1145
|
const pasteCommand = `paste '${filesPathes.join("' '")}'`;
|
|
1142
1146
|
// Construct the sort command dynamically based on the number of files for sorting
|
|
1143
|
-
const index =
|
|
1147
|
+
const index = 1;
|
|
1144
1148
|
const sortColumns = sortArray
|
|
1145
1149
|
.map(([key, ascending], i) => {
|
|
1146
1150
|
const field = Utils.getField(key, schema);
|
|
@@ -1178,8 +1182,13 @@ export default class Inibase {
|
|
|
1178
1182
|
// Extract values for each file, including `id${this.getFileExtension(tableName)}`
|
|
1179
1183
|
filesPathes.forEach((fileName, index) => {
|
|
1180
1184
|
const field = Utils.getField(parse(fileName).name, schema);
|
|
1181
|
-
if (field)
|
|
1182
|
-
|
|
1185
|
+
if (field) {
|
|
1186
|
+
if (field.key === "id" &&
|
|
1187
|
+
this.tablesMap.get(tableName).config.decodeID)
|
|
1188
|
+
outputObject[field.key] = splitedFileColumns[index];
|
|
1189
|
+
else
|
|
1190
|
+
outputObject[field.key] = File.decode(splitedFileColumns[index], field?.type, field?.children, this.salt);
|
|
1191
|
+
}
|
|
1183
1192
|
});
|
|
1184
1193
|
return outputObject;
|
|
1185
1194
|
});
|
|
@@ -1187,7 +1196,7 @@ export default class Inibase {
|
|
|
1187
1196
|
return restOfColumns
|
|
1188
1197
|
? outputArray.map((item) => ({
|
|
1189
1198
|
...item,
|
|
1190
|
-
...restOfColumns.find(({ id }) => id === item.id),
|
|
1199
|
+
...restOfColumns.find(({ id }) => id === (Utils.isNumber(item.id) ? Number(item.id) : item.id)),
|
|
1191
1200
|
}))
|
|
1192
1201
|
: outputArray;
|
|
1193
1202
|
}
|
package/dist/utils.server.js
CHANGED
|
@@ -221,6 +221,9 @@ export const isEqual = (originalValue, comparedValue, fieldType) => {
|
|
|
221
221
|
// If both are null-like, treat as equivalent
|
|
222
222
|
if (isOriginalNullLike && isComparedNullLike)
|
|
223
223
|
return true;
|
|
224
|
+
// If both are number-like
|
|
225
|
+
if (isNumber(originalValue) && isNumber(comparedValue))
|
|
226
|
+
return Number(originalValue) === Number(comparedValue);
|
|
224
227
|
// Direct equality check for other cases
|
|
225
228
|
return originalValue === comparedValue;
|
|
226
229
|
}
|