Monglorious!

Query MongoDB with Strings

Overview

Monglorious is a synchronous MongoDB client. Depending on the query, successful responses are always returned as either:

  • Value (number, string)
  • Collection of strings
  • Collection of maps

Back to top

Executing Queries

(execute connection-uri query)
(execute connection-options-or-uri db-name query)

Connects to a MongoDB database, executes a query, and returns the response. Closes the connection automatically after execution.

(execute-with-connection {:keys [conn db]} query)

Executes a query with an existing MongoDB connection, and leaves the connection open. Use to avoid a performance hit from repeated connection attempts. Use the (get-connection) function to open an initial connection.

Back to top

Connections

Monglorious supports standard MongoDB connection URIs, as well as Monger connection options. The same connection formats are available whether using (execute) or (execute-with-connection).

(get-connection connection-uri)
(get-connection connection-options-or-uri db-name)
Back to top

Supported Queries

Monglorious supports the following limited subset of the MongoDB shell commands:


    show dbs
    show databases
    show collections

    db.runCommand({ serverStatus: 1 })
    db.runCommand({ dbStats: 1 })
    db.runCommand({ whatmyuri: 1 })
    db.runCommand({ collStats: "<collection name>"})

    db.<collection>.find(<query>)
    db.<collection>.findOne(<query>)
    db.<collection>.count()
    db.<collection>.find(<query>).count()
    db.<collection>.find(...).sort(...).skip(...).limit(...)
    db.<collection>.insert(<document or documents>)
    db.<collection>.insertOne(<document>)
            

MongoDB functions are case-insensitive. Like the MongoDB shell, quotes are optional on object keys, and can be either single or double quotes.

db.runCommand() can either accept a map, or a string containing the command to run.

Back to top