inibase 1.1.17 → 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 +2 -3
- package/dist/index.js +11 -11
- package/package.json +1 -1
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,
|
|
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
|
-
|
|
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
|
@@ -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
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
return
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
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) {
|