Mongoose + Mlabs + Big amount of data

别来无恙 提交于 2020-01-15 06:12:06

问题


I use mongoose and react to fetch data from a mlab database. The probleme is that the mlab database have a size of 200 MB, it's a collection of more than 400 000 objects. So when i fetch i have JS error (out of memory) or the request is pending during 2 or 3 mins.

I don't know how to improve this request.

I also need to do some data formating and i don't know if it's better on back or front end..

I need your help to find a solution. Thanks a lot


回答1:


you can try

connection.model("myModel").find(query).limit(limit).skip(offset).exec()

query will be the condition of your search

limit will be the number of elements you want to load,

offset will be the number of elements you already have loaded and you want to skip



来源:https://stackoverflow.com/questions/49521721/mongoose-mlabs-big-amount-of-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!