Live data from Hacker News

Top 5 MongoDB gotchas

devblog.me

1–9 of 9 posts

Re: Top 5 MongoDB gotchas

#4

Wouldn't the simpler, faster and more appropriate syntax be if (N > 50 || N < 1) ??

It would be a simpler and shorter piece of code. Not sure why it would be faster though. Anyways, the point was in the behavior of `limit` which is easy to miss.

Re: Top 5 MongoDB gotchas

#5
So not only is performance abysmal, the query language has several non-obvious syntax problems. In retrospect, the idea of using JSON as a query language seems ill-advised and counter-intuitive.

I'm glad I am finally rid of MongoDB in my day-to-day job. I won't miss it.

Re: Top 5 MongoDB gotchas

#6

Wouldn't the simpler, faster and more appropriate syntax be if (N > 50 || N < 1) ??

No it wouldn't, because -30 is supposed to work the same as 30, so you want to convert the sign to positive first. Personally, I'd use something like:

    if (!N || Math.abs(N) > 50 ) {
        N = 50
    };

Re: Top 5 MongoDB gotchas

#7

So not only is performance abysmal, the query language has several non-obvious syntax problems. In retrospect, the idea of using JSON as a query language seems ill-advised and counter-intuitive. I'm glad I am finally rid of MongoDB in my day-to-day job. I won't miss it.

Well, those 5 are very specific corner cases. Most people will not face them in real life.

Re: Top 5 MongoDB gotchas

#8
post #7

So not only is performance abysmal, the query language has several non-obvious syntax problems. In retrospect, the idea of using JSON as a query language seems ill-advised and counter-intuitive. I'm glad I am finally rid of MongoDB in my day-to-day job. I won't miss it.

Well, those 5 are very specific corner cases. Most people will not face them in real life.

The array insert order syntax seems like something you'd encounter every day.

Re: Top 5 MongoDB gotchas

#9
Just to clarify on positive/negative limits on a cursor: if the limit number is negative, then the database will return that number of results and close the cursor. No further results for that query can be fetched. If the limit is positive you can leave the cursor open to receive further results, hence the option for both. (see http://stackoverflow.com/a/11995057/1148648)