-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export of components doesn't seem to work #1
Comments
Thanks for that, do you know if this was the same behaviour on the previous v4 plugin? Good point on the document id vs id. Not sure when I'll get chance to look at this |
Thanks for your response! In another strapi 4 project the plugin worked just fine as far as I remember. |
Hi @GraemeFulton Do you have any good news about the component supporting? |
Hi I think I'll get chance to look at this just after christmas - if anyone else can have a go in the meantime, pull request is very welcome! |
I am currently also looking at the code because I cant seem to get relations to import. They export fine. But I have other high pri features I need to focus on before I can look at anything here. |
I started building a fork to fix some of the issues I was personally having. I am not ready for a pull request, but I wanted to post here for those waiting for an update. There are enough significant changes that I am putting everything under a new v3 export type, primarily because 1: I never liked the way that you had to set a deepness level for how you want relations to be exported, and 2: Why is the assumption that if you are exporting entities on one collection that you want to also export all relations with it? So, list of some changes as of now: Quality of life change: added an export button in the "bulk action" area, so you can choose to only export records that are selected in the list view. Exports will now export both your published and draft version of a record. Draft will only be exported if it is different from the published version, and published will only be exported if one exists. If you have localized versions of records, they can also optionally be exported (working on the UI for this now). Exported entities are identified by the idField set in their schema, then fall back to a field labeled uid, then name, then title, and finally to standard id. Fixed alert styling. Started converting more of the codebase to typescript. On export, relations will only export the value of whatever your idField is, except for components, which are now not exported as relations, but rather as a sub array. I need to do more testing on dynamic zones though. Importing is smart enough to check if the value of idField changed between a published version and a draft version, but because I am not using the backend id, or documentId of a record, if you export a record, change the record's idField (name for example), then try to import the record from the old export, it will create a new record, because no record with that name currently exists. TODO: I want to reimplement a feature to export relations like it was before, but slightly different. Adding more options to control how things happen in the gui. I am going to add an intermediate step to importing data, so when you import, it will scan the data, then report back what it wants to do (i.e.: Create , Update , This record has errors, here they are <err1, err2>, it will be skipped, This record has a required relation to , but that related object doesn't exist, skipping import, etc). Then the user can comb through, make sure everything looks good and continue, or make changes. I didn't really intend on switch gears to working on something this big. I just need it to work. I have a different project I am trying to launch, and the only reason I dove into this was to mass import some data haha. If anyone wants to help me in this endeavor, by all means, pitch in. My goal is to get these changes into a good stable state where everything works and I'm not worried about data corruption (or warn the user if it is likely before they hit import) and then submit the pull request, but as you can see, there are still some things to work out. |
@Moonlight63 thanks for this, I think your changes make a lot of improvements for me too:
I never understood the deepness level, and found if i set the deepness value too high, it just fails. The v3 export type sounds great for me then. Maybe we can get rid of this deepness level version and just use yours as v1
That's great, it's a good upgrade to match Strapi 5 features
I think I had the same issues you explain in your rational for this - I just wanted to duplicate my production posts and keep relations in tact, but I could never do it with the current version There are a lot of changes, I think it helps everyone as the current version has many issues that you address - I'll give it a test when you're ready. Thanks again, really appreciate your efforts |
For todays update... I think I have the import validation pretty well figured out. Here is a diagram for anyone to
Here is a link to the code I think I might also need to add a new mode for importing when the importer runs into something like a list or array to control erase and recreate all array elements or append to existing elements. This only matters for imports that update existing elements. I have to admit, I didn't think there was going to be so much to do here. I am starting to see why this isn't just a default feature in Strapi, but it really still should be. If it was in the core, some of the hacky workarounds I am doing wouldn't be needed I feel. |
Lets call this a beta version: https://www.npmjs.com/package/strapi-import-export-v3?activeTab=readme FYI: This is working pretty well for my needs, but I don't make heavy use of locales. I think the way that locales are being handled is not going to be sustainable in the long term. I smell a v4. Happy New Year! |
hey @Moonlight63 thanks for this - I was away the last month, so sorry for the delay! I'll give this a go and hope to merge the pull request too! |
🐛 Bug Report
The export for collection types seems to work fine with relations to other collection types but not for components.
Maybe it's because strapi 5 uses documentId instead of id for reference or this breaking change https://docs.strapi.io/dev-docs/migration/v4-to-v5/breaking-changes/no-shared-population-strategy-components-dynamic-zones ?
The text was updated successfully, but these errors were encountered: