Monglorious!

Query MongoDB with Strings

Query MongoDB using Strings

Monglorious is a Clojure MongoDB client which accepts string queries, in the syntax of the MongoDB shell. This is in strict contrast to virtually every other MongoDB client which exposes a programmatic DSL in the target language.

(execute "mongodb://localhost:27017/testdb"
         "db.documents.find({ name: 'Xavier' })")

=> ({:_id #object[org.bson.types.ObjectId 0x7acd5871 "5815c9d9b160550f0eab8868"]
     :name "Xavier"
     :age 2
     :score 17772})
        

How Does it Work?

Queries are parsed with a custom-built grammar and translated into an abstract syntax tree, which is then in turn converted into the series of function calls to execute the specified query.

Why?

This library fills a niche of scenarios where MongoDB queries cannot be hard-coded into the specific function calls of an existing library. For example, a BI tool might allow an analyst to provide a MongoDB query to retrieve some data, similar to how it might allow a SQL query.

Can I Use Java?

Monglorious-java provides a Java wrapper of the Clojure library, aiming to provide an easy-to-use and idiomatic Java interface.