M
M
Mikhail Rybakov2015-09-15 15:49:06
MongoDB
Mikhail Rybakov, 2015-09-15 15:49:06

How to organize data upload on Node.js?

There is an API on Express.js (database on MongoDB) and a client - CMS on Angular.js. It is necessary to organize on the client the unloading of data from one of the collections (about 100k records) with saving to a CSV file. How best to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-09-15
@mrybakov

We read from mongi with a stream (like this: MyCollection.find({}).sort({}).stream()), then after simple transformations, we either write to a file (also with a stream) and then give it to nginx, or immediately give it to the browser. The first option is good because the result can be cached, and nginx is still more efficient than the node in such things, the second is stupidly simpler.
PS in principle, it is possible without streams - if there is a lot of memory on the server :)

L
lega, 2015-09-15
@lega

With mongoexport you can export to csv
i.e. start the process, and send the resulting file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question