inibase 1.1.28 → 1.1.30

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 CHANGED
@@ -159,9 +159,8 @@ const decodeHelper = (value, field) => {
159
159
  return isNumber(value) &&
160
160
  (!field.table ||
161
161
  !field.databasePath ||
162
- (!globalConfig[field.databasePath].tables?.get(field.table)?.config
163
- .decodeID &&
164
- field.key !== "id"))
162
+ !globalConfig[field.databasePath].tables?.get(field.table)?.config
163
+ .decodeID)
165
164
  ? encodeID(value)
166
165
  : value;
167
166
  default:
package/dist/index.js CHANGED
@@ -890,27 +890,32 @@ export default class Inibase {
890
890
  searchableIDs.set(lineNumber, lineContent);
891
891
  }
892
892
  if (searchableIDs.size) {
893
- const items = await this.get(field.table, Array.from(new Set(Array.from(searchableIDs.values()).flat())).flat(), {
893
+ const items = await this.get(field.table, Array.from(new Set(Array.from(searchableIDs.values()).flat()))
894
+ .flat()
895
+ .filter((item) => item), {
894
896
  ...options,
895
897
  perPage: Number.POSITIVE_INFINITY,
896
898
  columns: options.columns
897
899
  ?.filter((column) => column.includes(`${field.key}.`))
898
900
  .map((column) => column.replace(`${field.key}.`, "")),
899
901
  });
900
- for (const [lineNumber, lineContent] of searchableIDs.entries()) {
901
- RETURN[lineNumber][field.key] = Array.isArray(lineContent)
902
- ? Utils.isArrayOfArrays(lineContent)
903
- ? lineContent.map((item) => items
904
- ? items.find(({ id }) => item === id)
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)
905
908
  : {
906
- id: item,
907
- })
908
- : lineContent.flatMap((item) => items
909
- ? items.find(({ id }) => item === id)
910
- : { id: item })
911
- : (items?.find(({ id }) => id === lineContent) ?? {
912
- id: lineContent,
913
- });
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);
914
919
  }
915
920
  }
916
921
  }
@@ -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;
@@ -1010,6 +1017,7 @@ export default class Inibase {
1010
1017
  databasePath: this.databasePath,
1011
1018
  table: field.table ?? tableName,
1012
1019
  }, options.perPage, (options.page - 1) * options.perPage + 1, true);
1020
+ console.log(searchResult, totalLines, linesNumbers);
1013
1021
  if (searchResult) {
1014
1022
  const formatedSearchResult = Object.fromEntries(Object.entries(searchResult).map(([id, value]) => {
1015
1023
  const nestedObj = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",