inibase 1.1.12 → 1.1.13

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -641,7 +641,8 @@ export default class Inibase {
641
641
  return RETURN;
642
642
  }
643
643
  joinPathesContents(tableName, data) {
644
- const tablePath = join(this.databasePath, tableName), combinedData = this._CombineData(data);
644
+ const tablePath = join(this.databasePath, tableName);
645
+ const combinedData = this._CombineData(data);
645
646
  const newCombinedData = {};
646
647
  for (const [key, value] of Object.entries(combinedData))
647
648
  newCombinedData[join(tablePath, `${key}${this.getFileExtension(tableName)}`)] = value;
@@ -948,7 +949,9 @@ export default class Inibase {
948
949
  for await (const [key, value] of Object.entries(criteria)) {
949
950
  const field = Utils.getField(key, this.tablesMap.get(tableName).schema);
950
951
  index++;
951
- let searchOperator = undefined, searchComparedAtValue = undefined, searchLogicalOperator = undefined;
952
+ let searchOperator = undefined;
953
+ let searchComparedAtValue = undefined;
954
+ let searchLogicalOperator = undefined;
952
955
  if (Utils.isObject(value)) {
953
956
  if (value?.or &&
954
957
  Array.isArray(value?.or)) {
@@ -1106,7 +1109,8 @@ export default class Inibase {
1106
1109
  (Utils.isObject(where) && !Object.keys(where).length)))
1107
1110
  where = undefined;
1108
1111
  if (options.sort) {
1109
- let sortArray, awkCommand = "";
1112
+ let sortArray;
1113
+ let awkCommand = "";
1110
1114
  if (Utils.isObject(options.sort) && !Array.isArray(options.sort)) {
1111
1115
  // {name: "ASC", age: "DESC"}
1112
1116
  sortArray = Object.entries(options.sort).map(([key, value]) => [
@@ -1280,7 +1284,8 @@ export default class Inibase {
1280
1284
  return onlyOne
1281
1285
  ? linesNumbers.values().next().value
1282
1286
  : Array.from(linesNumbers);
1283
- const alreadyExistsColumns = Object.keys(Object.values(LineNumberDataMap)[0]), alreadyExistsColumnsIDs = Utils.flattenSchema(schema)
1287
+ const alreadyExistsColumns = Object.keys(Object.values(LineNumberDataMap)[0]);
1288
+ const alreadyExistsColumnsIDs = Utils.flattenSchema(schema)
1284
1289
  .filter(({ key }) => alreadyExistsColumns.includes(key))
1285
1290
  .map(({ id }) => id);
1286
1291
  RETURN = Object.values(Utils.deepMerge(LineNumberDataMap, await this.processSchemaData(tableName, Utils.filterSchema(schema, ({ id, type, children }) => !alreadyExistsColumnsIDs.includes(id) ||
@@ -1304,15 +1309,6 @@ export default class Inibase {
1304
1309
  totalPages: Math.ceil(greatestTotalItems / options.perPage),
1305
1310
  total: greatestTotalItems,
1306
1311
  };
1307
- // if (this.tablesMap.get(tableName).config.decodeID) {
1308
- // if (Array.isArray(RETURN)) {
1309
- // for (let index = 0; index < RETURN.length; index++)
1310
- // RETURN[index].id = UtilsServer.decodeID(
1311
- // RETURN[index].id as string,
1312
- // this.salt,
1313
- // );
1314
- // } else RETURN.id = UtilsServer.decodeID(RETURN.id as string, this.salt);
1315
- // }
1316
1312
  return onlyOne && Array.isArray(RETURN) ? RETURN[0] : RETURN;
1317
1313
  }
1318
1314
  async post(tableName, data, options, returnPostedData) {
@@ -1478,7 +1474,8 @@ export default class Inibase {
1478
1474
  (Array.isArray(where) && where.every(Utils.isValidID)) ||
1479
1475
  Utils.isValidID(where)) {
1480
1476
  const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
1481
- return this.put(tableName, clonedData, lineNumbers, options, false, true);
1477
+ if (lineNumbers)
1478
+ return this.put(tableName, clonedData, lineNumbers, options, returnUpdatedData, true);
1482
1479
  }
1483
1480
  else if (Utils.isObject(where)) {
1484
1481
  const lineNumbers = await this.get(tableName, where, undefined, undefined, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",