I assume that they too often forgot quotes and write {a: {>: 2}} . In JavaScript and some other languages, itโs quite normal to leave quotes when writing $gte (for example, {a: {$gte: 2, $lte: 4}} works like {"a": {"$gte": 2, "$lte": 4}} ). This allows you to print significantly when you try to execute queries in the Mongo shell.
I'm not sure if you are asking about this, but let me solve the question why the query language no longer resembles SQL, for example. why can't we write a query like a >= 2 && a <= 4 (except for the $where queries). The reason for this is that the only way to run this request is to parse JavaScript and run for each document. It would be impossible to use indexes, and each document would have to be converted from BSON data stored on disk to a JavaScript object in memory (and by the way, this is what happens when you execute a $where , group or reduce map request) .
The elegance of using JSON / BSON notations for queries is that they are pure data and can be processed and analyzed both on the client side and on the server side. On the server, the request is never transmitted through the JavaScript interpreter; rather, it is transmitted to the query planner, which selects it, formulates the plan, and executes it. On the client, the request can be built using its own data types in the client language and converted to a universal representation (i.e. BSON) only when transferred to the server.
source share