0

I am trying to find a good way to search for data in a big database. I have an API which get the entire list of data from MongoDB

.get(function(req, res) {
        drinks.find({ }, function(err, drinksOrders) {
            if (err) {
                res.send(err);
                return;
            }
            res.json(drinksOrders);
        });
    });

And i have ng-repeat to display those data with some filters.

**Question 1 - ** if my database files is 1gb, before the page load, will the page wait until res.json(drinksOrders) have been completely downloaded?

**Question 2 - ** if the page is loading dynamically without having to wait for the big json file to load, how would my search filter behave? So if in my search field "cola", this query will stand and angular will continuously download json and filtering out and displaying "cola" only?

**Question 3 - ** Using angular limitTo, will this only download part of json files to a certain limit.

Thank you

1 Answer 1

3

Well, I would say that this approach is wrong. If you load that much data to browser, you might kill it. The RAM and CPU consumption will be likely very high and your app will become unresponsive.

Better approach would be IMHO to use paging and always load say 50 items.

Do you REALLY need to load all data at once?

Ad 1) That depends on how you implement it. If you need ALL data to be loaded before user starts interacting with your page, then yes. Otherwise just add some loading indicator to the section which displays the drinks.

Ad 2) I am not sure, sorry :)

Ad 3) limitTo is a filter. It is used when rendering already loaded data. What it does it that it takes only first N items from available data. So all data needs to be loaded, before limitTo is applied

Sign up to request clarification or add additional context in comments.

2 Comments

Yes i dont want to load 1GB into a browser... that would be mad. Anyway thanks for the respond. What is IMHO?
IMHO means "In my humble opinion" :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.