PlayMongo can be used to

  1. test MongoDB and cMQL queries
  2. share code links
  3. save your queries in your account
  4. generate MQL from cMQL
  5. learn MQL and cMQL by exploring the ~300 examples from stackOverflow question (each question has a link stackoverflow question to read all the question)

Auto run & Auto-find-data

PlayMongo tracks the location of the cursor and

  • run queries up to that point (stage)
  • auto-finds the data before that point

Queries auto-run fast, and the previous data are auto-find so we can fast switch and see the data before and data after.

This allows users to write queries generally with 2 columns because on the right column there are always the data of the previous stage or the initial data.

  • column1 is code
  • column2 is the previous data (auto-found)


  • there is option to run with double click at any location (instead of auto)
  • view can change to add more columns, but the auto-run, auto-find-data reduces the need

Saving your queries

Share queries

All users can create permanent links using the share buttom

Save queries

With Share & Save, the query is saved in your account and appears your account left personal sidepane.
Other users can access the query only if they have the query link.

(Requires google log in)

Bookmark queries

Bookmark can be used to save any query(your query or from other user) in your account.
Only the query link is needed.

Usefull to keep the important queries separated.

(Requires google log in)

Share answers

Share answer button.This is only for stackoverflow and mongodb-forums answers.
Each query saved as answer should have a query link to the question.
The answers are added in the left sidepane to help other users.
If you want to save an answer but not in the public sidepane, select Share & Save

(Requires google log in)

Remove queries

You can remove a saved query, a saved answer or bookmark from your account. Links are permanent but it will be removed from your personal left sidepane.

(Requires log in, and to be the author of the query(if not bookmark))


Each query has optional metadata like bellow If you write a public answer you must add stackoverflow url or mongodb-forums url, so users to find the question. Public answers require one of those 2 urls. If you are logged in and you write a query your nickname is auto-added, you can remove it, or change, from the profile icon

"stackoverflow-question-url" : "",
"mongodbforums-question-url" : "",
"name" : "",
"description" : ""


2 Columns


The simple auto-view, for example when i am writing the $sort code, i see auto on the right the output of the $set.

Because queries auto-run fast, is like seeing almost the same time the data tranformations.

play example1

3 Columns

Useful when we examine a stage to see input and output the same time

play example1

4 Columns

Top right column can be

  • the results, to see them next to the query
  • the initial collections
  • the generated MQL code(if write cMQL) or the cMQL code, that produced that MQL

play example1

play example1


Data can be inserted in the following formats

  1. json/js objects (keys can be strings or symbols)
  2. clj maps (clj maps is like json but there is no need for : and , keys can be strings or keywords)

Single collection

[doc1 doc1 ...]
{"city" : "Athens"
"country" : "Greece"},
{"city" : "Paris"
"country" : "France"}

Multiple collections

{"city" : "Athens"
"country" : "Greece"},
{"city" : "Paris"
"country" : "France"},
{"city" : "Athens"
"population" : "4 Million"},
{"city" : "Paris"
"population" : "2 Million"}

Default coll names

Order of collections is their names also, starting from "1" For example js {"$lookup": {"from":"2" ...}} We put first the collection that we start the aggregation with.

User defined names

We can give custom names using the bellow syntax, unamed and named can be mixed

Named collection example

[coll1,nameColl2,coll2,coll3 ...]
{"city" : "Athens"
"country" : "Greece"},
{"city" : "Paris"
"country" : "France"},
{"city" : "Athens"
"population" : "4 Million"},
{"city" : "Paris"
"population" : "2 Million"}

Supported methods

cMQL-play is a subset of cMQL but the most important methods are supported.


  • (q ...) in cMQL
  • aggregate([...]) in MQL

No options is used


  • (uq ...) in cMQL (auto-separates the arguments)
  • update(query,update,options) in MQL

To upsert in cMQL use the (uq (upsert {..}) ...)
To upsert in MQL use the option {"upsert" : true}

To update one in cMQL use {"multi" : false} (many is the default in cMQL)
To update many in MQL use {"multi" : true}

You can use all other options like arrayFilters etc


  • (fq ...) in cMQL (auto-separates the arguments)
  • find(query,options) in MQL

cMQL play uses the Node.js driver style of call, for example sort/limit/projection are in options. This is done for simplicity, to not have many method calls.

For example

find({"k1" : "v1"},{"projection" : {"_id" : 0}, "limit" 5})


Comments for now are used with ; And in this line and in all lines bellow we can write comments. Comments are not supported for now inside the code.

Example queries

Learn MongoDB with examples

PlayMongo has ~300 examples in MQL and cMQL from stackoverflow questions. Each example has a link to the initial stackoveflow question to read it. Those examples can be used to learn MQL and cMQL.

Search the examples

You can search on the query its data and its metadata For example search for lookup can show 40+ lookup examples