All Questions

Coding Email

If you are implementing Export to CSV/JSON feature. What is the best approach?

Let’s say, I have 10k rows in DB. User want to export them all. Should I call GET endpoint to get data to frontend, then with library export to CSV/JSON? Or should I process data on backend, create CSV or JSON and send to email?

author WBE User

Reply
11 Answers

I would do it on the backend. What is the data size you’d be looking at for those 10k rows?

writen by Kyle K

Don’t know yet 😊 It’s my first time doing this

writen by WBE User

I implemented it on frontend and it works okay so far

writen by WBE User

3720 records exports instantly

writen by WBE User

Ah ok thats good then

writen by Kyle K

Yeah, for the start frontend should be ok. With more data you might want to backend processing, though.

writen by Benedikt

Okay. Seems like I’ll limit data export to some number at the start and implement it on backend in the future.

How should I handle then these big files? Send to email is not very good, because emails have some limited file size when sending, right? So should I store it in some S3 and give user link to download?

writen by WBE User

Yes, email is not the best approach here. You have multiple choices here: Start the job in the background and

  1. use i.e. WebSockets for pushing the result when it’s done (user might have left the side already so this is a bit tricky)
  2. use i.e. WebSockets or BrowserNotification for notifying the user about when the download is ready
  3. notify the user via email (including a link) when the file is ready

writen by Benedikt

3rd option looks good to me. Thanks!

writen by WBE User

For Real Email, I had 3 iterations of my CSV feature. Because I didnt know if anyone was going to use it, so I just build the next easiest thing that would solve the problem.

+1 for S3 though.

writen by Stephen N

10k rows -> csv -> s3

Actually, it should take a couple of seconds, so maybe you can give the link to the customer almost immediately so that they don’t have to wait for an email.

Email is still great though for saving them from losing the link.

writen by Kirill Rogovoy

Do you want to ask a question?


Related Questions