Operators overview
cMQL supports all aggregation operators see the API
Bellow are some more complicated ones.
For an overview see Example2
if cond
let
let allows depended variables also, producing the minimun possible nested $let
.
(for now don't define the same variable multiple times in the same let
)
- cMQL
- MQL
map filter reduce
*if i don't want names for the arguments i can use :value. or :this. like
functions defmfn defnmfn
MQL doens't have functions
But we can use the driver and cMQL like functions
driver functions
If we want to use a function to generate cMQL we can do it,using the macro cmql like
This can be used for code re-use or for very big queries
mongo functions
MQL doens't have functions for map/filter/reduce it uses a variable key "vars",and a body "in"
cMQL makes them look like normal functions
But we can go even futher and def them as independent functions
defnmfn Allows normal clojure code to be used, we call them before we use them see bellow
defmfn We declare them as mongo-functions,they use mongo-variables inside the body,and they dont take arguments when are called.
All those functions can only be use cMQL operators(or raw MQL) in their body,but because cMQL is like Clojure we can have clojure code re-use.
If we want to use clojure inside them we can use c/str (c alias for clojure.core)