Why cMQL for Javascript

General reasons

  • less code up to 3x
  • simple structure
  • simple notation
  • simple interop call as js function, get js data back without tranformations

Javascript programmers can use

Here is explained how to use cMQL, to call it from Javascript code. For more info about cMQL and why is useful see what? and why?.
Javascript programmers use cMQL-js

How to use

  • write the cMQL queries as seperate project,or add the clojure code inside the java project
  • call them from nodejs app

Clojurescript functions are javascript functions and its easy to call without any interop.

Compile the Clojurescript-app

The nodeapp contains a clojurescript-app example (its in a folder inside the node app).

  • rm -rf ../.shadow-cljs (delete the nodeapp/.shadow-cljs) to clean previous runs
  • rm -rf ../queries (delete the nodeapp/queries) to clean previous runs
  • java -jar usecljs-0.1.0-SNAPSHOT-standalone.jar 0 (make the :use comment, :use is used only for autocomplete of ide but clojurescript dont support it)
  • shadow-cljs compile library (compile as library, this will create a nodeapp/queries this is a npm module that we will require)
  • java -jar usecljs-0.1.0-SNAPSHOT-standalone.jar 1 (un-comment the :use again, to leave the project as it was)
  • cp -R ./.shadow-cljs ../.shadow-cljs (to copy it to nodeapp/.shadow-cljs, this folder has compile information that we need)


We can run now the nodejs app, and call the functions we exported, see shadow-cljs.edn the :library

Clojurescript-app provides for each query 2 call ways

  • without callback function => return promise , like await queries.q1js();
  • with callback function => call with the result like queries.q1js(q1cb);

Callback example

var queries=require("./queries/clojurescriptapp.core");
var q1cb = function (r){console.log(r);} //just print the results