feat: implement arrays of nested objects upload functionality #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to upload an array of nested objects that can each have an (upload) file.
The use case is where you want to store a number of nested objects that can each have (upload) files. For example an array of photos on a (blog) post:
To achieve this I have added a new option (
parentArray
) to theuploadFeature
options. TheparentArray
option indicates that the (upload) feature should be nested under a parent array property.For the above
post
example (withphotos
) theuploadFeature
options would be something like:The code handles the
parentArray
case by building the properties "on the fly", to match the items array of photos. Sofile
gets mapped tophotos.0.file
,photos.1.file
, etc.,I was hoping this would be achievable with fewer changes, but unfortunately it resulted in a fairly significant rewrite in particular of
updateRecordFactory
, which it now handles multiple uploads in a single call toupdateRecord
.If you are interested in including this feature then I can add an example and tests for the new cases along with any improvements / alterations that you require, but I first wanted to get an indication of whether you see this as a worthwhile addition.
If not I could publish it as an
upload-array-file
feature.Please let me know if you have some contribution or similar guidelines that I have missed.
Thanks for your time and for providing a great library!