问题
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