Write MongoDB find queries

In DevOpsPad, a MongoDB query is one JSON object describing a find: the collection to read plus optional filter, projection, sort, skip and limit. Press ⌘ / Ctrl + Enter to run it against the database selected for the tab.

The editor does not accept shell syntax such as db.orders.find({...}), and it rejects fields it does not know. That keeps every query a read.

The query format

{
  "collection": "orders",
  "filter": { "status": "paid", "total": { "$gte": 100 } },
  "projection": { "customer": 1, "total": 1, "createdAt": 1 },
  "sort": { "createdAt": -1 },
  "skip": 0,
  "limit": 100
}
Field Required Rules
collection Yes Collection name in the tab’s database
filter No A JSON object. Empty or missing means {}. Accepts Extended JSON
projection No A JSON object, for example { "name": 1, "_id": 0 }
sort No A JSON object. Each direction must be 1 or -1. Field order is kept
skip No 0 to 1,000,000. Default 0
limit No 1 to 500. Default 100

Any other field, such as pipeline or update, fails with Invalid find query: json: unknown field …. Enter one object per run; a second object fails with Enter one JSON find query. The query text can be up to 1 MB.

Sorting and the _id tie-breaker

If sort does not include _id, DevOpsPad appends "_id": 1. That gives every document a stable position, so Previous batch and Next batch do not skip or repeat documents when many share the same sort value.

Reading results

A MongoDB find query with a projection and sort in the editor, the result grid showing one document, and Previous batch and Next batch buttons below it.

Each result row is one document in the document column, shown as canonical Extended JSON so types such as ObjectId, dates and 64-bit integers stay exact. Double-click a row to inspect it, or use Export CSV.

Errors

Message Fix
A collection name is required Add "collection"
Select a database before running a find query Pick a database in the Explorer, then open a new tab
Limit must be between 1 and 500 Lower limit
Skip must be between 0 and 1000000; use a range filter for deeper pagination Filter on a range instead, see batches
Sort directions must be 1 or -1 Replace values such as "desc"
Result exceeds 8 MB; reduce the limit or use a projection Return fewer fields or fewer documents

Limits

  • Find only. Aggregation, count, distinct and document editing are not available.
  • MongoDB stops a query after 15 seconds (maxTimeMS), and the desktop request has a 20-second timeout.
  • Results are capped at 500 documents and 8 MB per batch.

Frequently asked questions

Can I run aggregation pipelines in DevOpsPad?

No. The MongoDB editor runs find queries only. Aggregation is not available in this version.

What is the default limit for a MongoDB query?

100 documents. You can set limit from 1 to 500.