inibase 1.0.0-rc.113 → 1.0.0-rc.114

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 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -411,19 +411,21 @@ export default class Inibase {
411
411
  this.checkIFunique = {};
412
412
  }
413
413
  formatData(data, schema, formatOnlyAvailiableKeys) {
414
- if (Utils.isArrayOfObjects(data))
415
- return data.map((single_data) => this.formatData(single_data, schema, formatOnlyAvailiableKeys));
416
- if (Utils.isObject(data)) {
414
+ const clonedData = JSON.parse(JSON.stringify(data));
415
+ if (Utils.isArrayOfObjects(clonedData))
416
+ return clonedData.map((singleData) => this.formatData(singleData, schema, formatOnlyAvailiableKeys));
417
+ if (Utils.isObject(clonedData)) {
418
+ const RETURN = {};
417
419
  for (const field of schema) {
418
- if (!Object.hasOwn(data, field.key)) {
420
+ if (!Object.hasOwn(clonedData, field.key)) {
419
421
  if (formatOnlyAvailiableKeys)
420
422
  continue;
421
- data[field.key] = this.getDefaultValue(field);
423
+ RETURN[field.key] = this.getDefaultValue(field);
422
424
  continue;
423
425
  }
424
- data[field.key] = this.formatField(data[field.key], field.type, field.children, formatOnlyAvailiableKeys);
426
+ RETURN[field.key] = this.formatField(clonedData[field.key], field.type, field.children, formatOnlyAvailiableKeys);
425
427
  }
426
- return data;
428
+ return RETURN;
427
429
  }
428
430
  return [];
429
431
  }
@@ -1195,7 +1197,7 @@ export default class Inibase {
1195
1197
  // Skip ID and (created|updated)At
1196
1198
  this.validateData(data, schema.slice(1, -2), true);
1197
1199
  await this.checkUnique(tableName, schema);
1198
- this.formatData(data, schema, true);
1200
+ data = this.formatData(data, schema, true);
1199
1201
  const pathesContents = this.joinPathesContents(tableName, {
1200
1202
  ...(({ id, ...restOfData }) => restOfData)(data),
1201
1203
  updatedAt: Date.now(),
@@ -1233,7 +1235,7 @@ export default class Inibase {
1233
1235
  // "where" in this case, is the line(s) number(s) and not id(s)
1234
1236
  this.validateData(data, schema.slice(1, -2), true);
1235
1237
  await this.checkUnique(tableName, schema.slice(1, -2));
1236
- this.formatData(data, schema, true);
1238
+ data = this.formatData(data, schema, true);
1237
1239
  const pathesContents = Object.fromEntries(Object.entries(this.joinPathesContents(tableName, Utils.isArrayOfObjects(data)
1238
1240
  ? data.map((item) => ({
1239
1241
  ...item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.0.0-rc.113",
3
+ "version": "1.0.0-rc.114",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",