inibase 1.2.10 → 1.2.11

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 +23 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -696,19 +696,19 @@ export default class Inibase {
696
696
  for (const field of schema) {
697
697
  // If the field is of simple type (non-recursive), process it directly
698
698
  if (this.isSimpleField(field.type)) {
699
- await this.processSimpleField(tableName, field, linesNumber, RETURN, options, prefix);
699
+ await this.processSimpleField(tableName, field, RETURN, linesNumber, prefix);
700
700
  }
701
701
  else if (this.isArrayField(field.type)) {
702
702
  // Process array fields (recursive if needed)
703
- await this.processArrayField(tableName, field, linesNumber, RETURN, options, prefix);
703
+ await this.processArrayField(tableName, field, RETURN, linesNumber, options, prefix);
704
704
  }
705
705
  else if (this.isObjectField(field.type)) {
706
706
  // Process object fields (recursive if needed)
707
- await this.processObjectField(tableName, field, linesNumber, RETURN, options, prefix);
707
+ await this.processObjectField(tableName, field, RETURN, linesNumber, options, prefix);
708
708
  }
709
709
  else if (this.isTableField(field.type)) {
710
710
  // Process table reference fields
711
- await this.processTableField(tableName, field, linesNumber, RETURN, options, prefix);
711
+ await this.processTableField(tableName, field, RETURN, linesNumber, options, prefix);
712
712
  }
713
713
  }
714
714
  return RETURN;
@@ -721,7 +721,7 @@ export default class Inibase {
721
721
  return !complexTypes.includes(fieldType);
722
722
  }
723
723
  // Process a simple field (non-recursive)
724
- async processSimpleField(tableName, field, linesNumber, RETURN, _options, prefix) {
724
+ async processSimpleField(tableName, field, RETURN, linesNumber, prefix) {
725
725
  const fieldPath = join(this.databasePath, tableName, `${prefix ?? ""}${field.key}${this.getFileExtension(tableName)}`);
726
726
  if (await File.isExists(fieldPath)) {
727
727
  const items = await File.get(fieldPath, linesNumber, {
@@ -751,13 +751,13 @@ export default class Inibase {
751
751
  fieldType === "array");
752
752
  }
753
753
  // Process array fields (recursive if needed)
754
- async processArrayField(tableName, field, linesNumber, RETURN, options, prefix) {
754
+ async processArrayField(tableName, field, RETURN, linesNumber, options, prefix) {
755
755
  if (Array.isArray(field.children)) {
756
756
  if (this.isSimpleField(field.children)) {
757
- await this.processSimpleField(tableName, field, linesNumber, RETURN, options, prefix);
757
+ await this.processSimpleField(tableName, field, RETURN, linesNumber, prefix);
758
758
  }
759
759
  else if (this.isTableField(field.children)) {
760
- await this.processTableField(tableName, field, linesNumber, RETURN, options, prefix);
760
+ await this.processTableField(tableName, field, RETURN, linesNumber, options, prefix);
761
761
  }
762
762
  else {
763
763
  let _fieldChildren = field.children;
@@ -835,10 +835,10 @@ export default class Inibase {
835
835
  }
836
836
  else if (this.isSimpleField(field.children)) {
837
837
  // If `children` is FieldType, handle it as an array of simple types (no recursion needed here)
838
- await this.processSimpleField(tableName, field, linesNumber, RETURN, options, prefix);
838
+ await this.processSimpleField(tableName, field, RETURN, linesNumber, prefix);
839
839
  }
840
840
  else if (this.isTableField(field.children)) {
841
- await this.processTableField(tableName, field, linesNumber, RETURN, options, prefix);
841
+ await this.processTableField(tableName, field, RETURN, linesNumber, options, prefix);
842
842
  }
843
843
  }
844
844
  // Helper function to check if the field type is object
@@ -849,7 +849,7 @@ export default class Inibase {
849
849
  fieldType.includes("object")));
850
850
  }
851
851
  // Process object fields (recursive if needed)
852
- async processObjectField(tableName, field, linesNumber, RETURN, options, prefix) {
852
+ async processObjectField(tableName, field, RETURN, linesNumber, options, prefix) {
853
853
  if (Array.isArray(field.children)) {
854
854
  // If `children` is a Schema (array of Field objects), recurse
855
855
  const items = await this.processSchemaData(tableName, field.children, linesNumber, options, `${prefix ?? ""}${field.key}.`);
@@ -873,7 +873,7 @@ export default class Inibase {
873
873
  fieldType.includes("table")));
874
874
  }
875
875
  // Process table reference fields
876
- async processTableField(tableName, field, linesNumber, RETURN, options, prefix) {
876
+ async processTableField(tableName, field, RETURN, linesNumber, options, prefix) {
877
877
  if (field.table &&
878
878
  (await File.isExists(join(this.databasePath, field.table)))) {
879
879
  const fieldPath = join(this.databasePath, tableName, `${prefix ?? ""}${field.key}${this.getFileExtension(tableName)}`);
@@ -899,7 +899,7 @@ export default class Inibase {
899
899
  .flat()
900
900
  .filter((item) => item), {
901
901
  ...options,
902
- perPage: Number.POSITIVE_INFINITY,
902
+ perPage: -1,
903
903
  columns: options.columns
904
904
  ?.filter((column) => column.includes(`${field.key}.`))
905
905
  .map((column) => column.replace(`${field.key}.`, "")),
@@ -960,7 +960,7 @@ export default class Inibase {
960
960
  if (field.table && Utils.isObject(value)) {
961
961
  const items = await this.get(field.table, value, {
962
962
  columns: "id",
963
- perPage: Number.POSITIVE_INFINITY,
963
+ perPage: -1,
964
964
  });
965
965
  if (items?.length)
966
966
  value = `[]${items.map(({ id }) => id)}`;
@@ -1013,8 +1013,10 @@ export default class Inibase {
1013
1013
  ...field,
1014
1014
  databasePath: this.databasePath,
1015
1015
  table: field.table ?? tableName,
1016
- }, options.perPage, (options.page - 1) * options.perPage +
1017
- (options.page > 1 ? 1 : 0), true);
1016
+ }, options.perPage < 0 ? undefined : options.perPage, options.perPage < 0
1017
+ ? undefined
1018
+ : (options.page - 1) * options.perPage +
1019
+ (options.page > 1 ? 1 : 0), true);
1018
1020
  if (!searchResult) {
1019
1021
  if (allTrue)
1020
1022
  return null;
@@ -1223,9 +1225,11 @@ export default class Inibase {
1223
1225
  }
1224
1226
  if (!where) {
1225
1227
  // Display all data
1226
- RETURN = Object.values(await this.processSchemaData(tableName, schema, Array.from({ length: options.perPage }, (_, index) => (options.page - 1) * options.perPage +
1227
- index +
1228
- 1), options));
1228
+ RETURN = Object.values(await this.processSchemaData(tableName, schema, options.perPage < 0
1229
+ ? undefined
1230
+ : Array.from({ length: options.perPage }, (_, index) => (options.page - 1) * options.perPage +
1231
+ index +
1232
+ 1), options));
1229
1233
  if (!this.totalItems.has(`${tableName}-*`))
1230
1234
  this.totalItems.set(`${tableName}-*`, pagination[1]);
1231
1235
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",