Hi, you are trying to load to much data in memory at once.

Usually to do this, people should use “pagination”, which with mongo is just using “skip” and “limit” options. Here https://codeforgeek.com/server-side-pagination-using-node-and-mongo/ you have an example. You also have to manage the pagination in the client side, sending que actual page and maybe even the pageSize to the server.

Other option without pagination is using streams. You have to read all data from database and connect this input stream with the output stream in the response object.Here https://medium.com/yld-blog/using-streams-readable-writable-transform-streams-and-flow-control-d45c280b13f0 an article about streams. Basically (I think), when you have the ReadStream `const stream = DataModel.find({}).lean().cursor();` you can just stream.pipe(res) .