Live data from Hacker News

MongoDB Is Abusing JSON

smsohan.com

1–10 of 61 posts

Re: MongoDB Is Abusing JSON

#4
MongoDB is a NoSQL-type database, so it wouldn't make sense to have a SQL query interface... I think they did a good job with the API for not using SQL.

Plus, the API isn't really abusing JSON. It isn't pretty, but it's not abuse.

Re: MongoDB Is Abusing JSON

#5
JSON is used as a query language because it's fast, easy to parse and easy to generate dynamically. If you have a query interface for users, SQL is probably a better choice, but Mongo chose JSON for performance reasons.

If you don't like dealing with it directly, use something like MongoEngine so you're not working with the raw queries, or if having readable, easy to understand queries is important, use a SQL database.

Everything is a compromise, with Mongo's query language you're sacrificing readability for performance.

( This is not a comparison of a SQL database to Mongo, just the time it takes for a SQL engine to parse the query into an execution plan )

Re: MongoDB Is Abusing JSON

#8
Here's what this query looks like in RethinkDB (also based on JSON documents):

  r.table('orders')
   .pluck('cust_id','ord_date','price')
   .groupBy('cust_id','ord_date', r.sum('price')).
   .filter(r.row('reduction').gt(250))
We use the hard-coded attribute 'reduction' because groupBy automatically gets compiled to our distributed map-reduce infrastructure. There is currently no as command (though it could easily be simulated with map). I'll add a GitHub issue for this shortly, since we should add sugar for it.

Re: MongoDB Is Abusing JSON

#9
You picked an ugly mongo query, and there are many. You compared it to a concise SQL query, and there are many that are not.

MongoDB's limit(x) and skip(y) are a shitload nicer than most of Microsoft's ideas about pagination. It was only in SQL Server 2012 that they came up with "OFFSET" instead of "google it".... http://stackoverflow.com/questions/2244322/how-to-do-paginat...

Re: MongoDB Is Abusing JSON

#10
I don't think it's fair to take JSON out of context from the rest of the query API. Or maybe it's being overly generous, I'm not sure. Either way, this is the same way object literals are constructed in JavaScript. So is the beef w/JavaScript?

For me the Mongo shell is just enough so-called "richness" and "expressiveness" (Try it yourself: http://try.mongodb.org/). There's a certain magic to passing objects to functions (and being able to, say, read the body of a function by typing that object into the CLI).

Post reply on HN