inibase 1.1.16 → 1.1.18

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
@@ -5,7 +5,7 @@ import { Transform } from "node:stream";
5
5
  import { pipeline } from "node:stream/promises";
6
6
  import { createGunzip, createGzip } from "node:zlib";
7
7
  import Inison from "inison";
8
- import { detectFieldType, isArrayOfObjects, isStringified, isNumber, isObject, } from "./utils.js";
8
+ import { detectFieldType, isArrayOfObjects, isNumber, isObject, isStringified, } from "./utils.js";
9
9
  import { compare, encodeID, exec, gunzip, gzip } from "./utils.server.js";
10
10
  export const lock = async (folderPath, prefix) => {
11
11
  let lockFile = null;
@@ -547,8 +547,7 @@ export const search = async (filePath, operator, comparedAtValue, logicalOperato
547
547
  const decodedLine = decode(line, fieldType, fieldChildrenType, secretKey);
548
548
  // Check if the line meets the specified conditions based on comparison and logical operators.
549
549
  const doesMeetCondition = (Array.isArray(decodedLine) &&
550
- !Array.isArray(decodedLine[1]) &&
551
- decodedLine.some(meetsConditions)) ||
550
+ decodedLine.flat().some(meetsConditions)) ||
552
551
  meetsConditions(decodedLine);
553
552
  // If the line meets the conditions, process it.
554
553
  if (doesMeetCondition) {
package/dist/index.js CHANGED
@@ -902,7 +902,7 @@ export default class Inibase {
902
902
  const foundedItem = isArrayField
903
903
  ? Utils.isArrayOfArrays(lineContent)
904
904
  ? lineContent.map((item) => items.filter(({ id }) => item.includes(id)))
905
- : lineContent.flatMap((item) => items.filter(({ id }) => item.includes(id)))
905
+ : lineContent.flatMap((item) => items.find(({ id }) => item === id))
906
906
  : items.find(({ id }) => id === lineContent);
907
907
  if (foundedItem)
908
908
  RETURN[lineNumber][field.key] = foundedItem;
@@ -1265,18 +1265,18 @@ export default class Inibase {
1265
1265
  else if (Utils.isObject(where)) {
1266
1266
  let cachedFilePath = "";
1267
1267
  // Criteria
1268
- if (this.tablesMap.get(tableName).config.cache)
1268
+ if (this.tablesMap.get(tableName).config.cache) {
1269
1269
  cachedFilePath = join(tablePath, ".cache", `${UtilsServer.hashString(inspect(where, { sorted: true }))}${this.fileExtension}`);
1270
- if (this.tablesMap.get(tableName).config.cache &&
1271
- (await File.isExists(cachedFilePath))) {
1272
- const cachedItems = (await readFile(cachedFilePath, "utf8")).split(",");
1273
- if (!this.totalItems.has(`${tableName}-*`))
1274
- this.totalItems.set(`${tableName}-*`, cachedItems.length);
1275
- if (onlyLinesNumbers)
1276
- return onlyOne ? Number(cachedItems[0]) : cachedItems.map(Number);
1277
- return this.get(tableName, cachedItems
1278
- .slice((options.page - 1) * options.perPage, options.page * options.perPage)
1279
- .map(Number), options, onlyOne, undefined, true);
1270
+ if (await File.isExists(cachedFilePath)) {
1271
+ const cachedItems = (await readFile(cachedFilePath, "utf8")).split(",");
1272
+ if (!this.totalItems.has(`${tableName}-*`))
1273
+ this.totalItems.set(`${tableName}-*`, cachedItems.length);
1274
+ if (onlyLinesNumbers)
1275
+ return onlyOne ? Number(cachedItems[0]) : cachedItems.map(Number);
1276
+ return this.get(tableName, cachedItems
1277
+ .slice((options.page - 1) * options.perPage, options.page * options.perPage)
1278
+ .map(Number), options, onlyOne, undefined, true);
1279
+ }
1280
1280
  }
1281
1281
  const [LineNumberDataMap, linesNumbers] = await this.applyCriteria(tableName, options, where);
1282
1282
  if (LineNumberDataMap && linesNumbers?.size) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",