cMQL as tool

  • cMQL generates MQL and
  • MQL can be embeded in code or parsed
    for example Document doc = Document.parse("{\"foo\":1}"); or Document doc = Document.parse(readFile(q1));
  • json support allows us to run MQL queries in all drivers

This method is easiest way to try cMQL, without writting a cMQL app.
But it can be used also as a method to use cMQL/MQL in general.

Embeded MQL

Manual way, copy paste the code, replace possible variables by hand.

  • cMQL-Play write cMQL or local auto-convert
  • (q (= :age 25)) generates
  • [{"$match": {"$expr": {"$eq": ["$age", 25]}}}] paste it in code
  • make few changes if needed like add driver variables etc

Parsed MQL

Automated way, generate code, auto dynamic replace variables.

Here an example will be used that the variables are auto-replaced also $$$age is a random way to symbolize the driver variable name.

  • cMQL-Play write cMQL, or local auto-convert
  • (q (= :age "$$$age")) generates
  • [{"$match": {"$expr": {"$eq": ["$age", "$$$age"]}}}] save to a text file q1.json
  • at run-time call like
    q1= parse(q1JSON)
    argHash={"age" age, ....}
    ;;a loop to replace the args, "$$$age" will take the age value
  • cost of making a text file to json, and replace the variables its almost zero, queries are so small data structures

instead of cmql-live, this can be done local and automated
for example all queries in a directory q1,q2 ... converted to q1.json,q2.json

This automatic-way requires some a cmql-app to convert that directory of cmql queries,
and some driver specific code to add the dynamic args


  • the easiest way to try cMQL
  • can be made to work in all drivers
  • cost is practical zero

But for the languages that cMQL supports, there is even simpler way with a simple function call to a cMQL app.
(clojure is made for easy interop)