inibase 1.2.7 → 1.2.8
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/index.js +9 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -440,11 +440,12 @@ export default class Inibase {
|
|
|
440
440
|
formatField(value, field, _formatOnlyAvailiableKeys) {
|
|
441
441
|
if (value === null || value === undefined || value === "")
|
|
442
442
|
return value;
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
443
|
+
let _fieldType = field.type;
|
|
444
|
+
if (Array.isArray(_fieldType))
|
|
445
|
+
_fieldType = Utils.detectFieldType(value, _fieldType) ?? _fieldType[0];
|
|
446
|
+
if (Array.isArray(value) && !["array", "json"].includes(_fieldType))
|
|
446
447
|
value = value[0];
|
|
447
|
-
switch (
|
|
448
|
+
switch (_fieldType) {
|
|
448
449
|
case "array":
|
|
449
450
|
if (!field.children)
|
|
450
451
|
return null;
|
|
@@ -759,8 +760,9 @@ export default class Inibase {
|
|
|
759
760
|
await this.processTableField(tableName, field, linesNumber, RETURN, options, prefix);
|
|
760
761
|
}
|
|
761
762
|
else {
|
|
763
|
+
let _fieldChildren = field.children;
|
|
762
764
|
// Handling array of objects and filtering nested arrays
|
|
763
|
-
const nestedArrayFields =
|
|
765
|
+
const nestedArrayFields = _fieldChildren.filter((children) => children.type === "array" &&
|
|
764
766
|
Utils.isArrayOfObjects(children.children));
|
|
765
767
|
if (nestedArrayFields.length > 0) {
|
|
766
768
|
// one of children has array field type and has children array of object = Schema
|
|
@@ -769,10 +771,10 @@ export default class Inibase {
|
|
|
769
771
|
for (const [index, item] of Object.entries(childItems))
|
|
770
772
|
this._processSchemaDataHelper(RETURN, item, index, field);
|
|
771
773
|
// Remove nested arrays after processing
|
|
772
|
-
|
|
774
|
+
_fieldChildren = _fieldChildren.filter((children) => !nestedArrayFields.map(({ key }) => key).includes(children.key));
|
|
773
775
|
}
|
|
774
776
|
// Process remaining items for the field's children
|
|
775
|
-
const items = await this.processSchemaData(tableName,
|
|
777
|
+
const items = await this.processSchemaData(tableName, _fieldChildren, linesNumber, options, `${(prefix ?? "") + field.key}.`);
|
|
776
778
|
// Process the items after retrieval
|
|
777
779
|
if (items) {
|
|
778
780
|
for (const [index, item] of Object.entries(items)) {
|