Hi guys, i’ need a way to change multiple specifcics fields in a specific content-type using strapi.
– Example: i have multiple users already registred in my database, and each user have a field with address, some users haven’t informed their address.
But now, with some csv/google docs search ( or a form ) i have more info and more address of my users, and now i need to update everyone’s address fields, but imagine i have more then 1000 address for update, its possible to update all them using csv in strapi ?
There are roughly 2 or 3 ways to make bulk updates but none of them are directly native to Strapi:
The simplest way is simply performing a loop on the client side, this provides the best fault tolerance to the frontend, where in case of a failure it wouldn’t entirely stop the process and errors with specific entries could be handled gracefully with ease.
The following two require custom controllers/routes within Strapi:
Either you do the same loop but server-side where the client basically just sends a payload that is an array of objects. This is slower since you couldn’t utilize load balancing and handling errors is not as simple (how do you tell the client that 2/10 in the array had errors?)
The other method involves more custom logic in a controller which could utilize custom queries (aka bypassing strapi logic) and doing an actual database level bulk insert/update, it’s at this point where you could probably parse a CSV and convert it to the structure needed in a custom query. This would be the fastest method but would pose the same error handling problem. It’s also the most complex to do.
And i have just one more question, its about strapi plugin, in your opinion, you imagine its more easy to add a custom logic to add and extract a CSV data directly using the strapi interface with an plugin or one specific button then updates/create multiple things.
Depends, I’ve tested solutions like this in the past by sending an API request to parse a CSV but it was pretty dirty and didn’t handle errors well. (It’s been over a year so I probably don’t have that same code anywhere and even if I did it would be largely out of date).
Building a custom node script to handle something like this would probably be easier.