MQL support
MQL and cMQL can be mixed freely
But cMQL wraps all aggregation stages/operators so generally there is no need
For example i can have a MQL stage,that uses also a cMQL operator
The bellow notation is to make MQL easier they dont restrict MQL
Fields
Keyword on the left of a map is just a string
Field references
Keyword everywhere else is a reference (references cant be keys so there is no conflict)
Variables
System variables
Example(fields,references,variables)
*keywords are auto-completed in IDE's for example cursive helps on that
Filter ()
Filters one after another become 1 $match stage,with $and and $expr added.
Don't use as filters things like bellow see [Query operators and Update operators]
Project []
AddFields {}
*In the rare case where we want to add a field that has the name of a command option
Pipeline
- nil/empty stages are removed This allows to have conditional stages
- nested stages(even if many levels) becomes flatten
This allows functions to generate 2 or more stages that added to the pipeline
Example(pipeline)
Aggregation framework
cMQL approach is
- use aggregation
- implement the operator with other aggregation operators
- use raw MQL inside cMQL (for example the bellow match)
- use javascript
- use the driver methods
- use MQL commands
cMQL commands uses aggregation operators for query and for pipelines for updates. To use cMQL MongoDB >= 4.2 is needed and to use the javascript in aggregation MongoDB >= 4.4 is needed
The reason is to be easy and program in 1 way
Aggregation framework can do almost all that query or update operators can do
and much more
If something is needed it can be added in the future
Query and Update operators
cMQL uses aggregation by default
Query operators can be used but in raw MQL
(match { "price" { "$ne" 1.99 "$exists" true }})cMQL supports the find command but it makes it look like pipeline also For example the above would be (internaly is a find , not aggregation)
(fq :foo.bar(not= :price 1.99)(exists? :price))Update operators are not wrapped from cMQL
Driver methods can be used or MQL update commandscMQL pipepline updates has operators like get-in and assoc-in that allows complex updates to be easily done
(assoc-in :channel[{:cond (=_ :o.name. "switch") :kcond (= :k "formats")} ;;key by condition{:icond (=_ :v.formatName. "ISO8583-93")} ;;index by condition5 ;;array index"alias"] ;;document key"newAlias")
Commands
cMQL commands are similar to MQL but not completly the same The reason is to provide less verbose and intuitive commands
Command options
Commands options can be given as
More Info
For more info see documentation,the API and the docstrings