Query MongoDB in plain English

Ask the question the same way you would of any database. For MongoDB there is no SQL to write, so ByeSQL builds the aggregation pipeline instead, runs it read-only, and gives you back a table, a chart or a dashboard panel.

Aggregation pipelines, not SQLSchema inferred by samplingWrite stages blocked

Nothing about the experience changes

The query language underneath does. Everything you touch does not.

Writing it yourself
  • Know which collection holds the answer
  • Remember the stage order and the operator names
  • Get $group and $lookup right by hand
  • Find out your documents are not uniform the hard way
With ByeSQL
  • Describe what you want to know
  • The pipeline is built against the shape your data actually has
  • It runs and you see the pipeline it used
  • Follow-ups refine the previous one instead of starting over

How it learns a schemaless database

There is no information_schema to read, so ByeSQL looks at the documents themselves: the first 100 of each collection.

Fields, including nested ones

Field paths are collected through nested documents, so address.city is as visible as a top-level field.

Every type it sees

When a field holds more than one type across the sample, all of them are recorded rather than one being picked and the rest ignored.

What is optional

A field missing from part of the sample is marked optional. _id is the primary key, and unique single-field indexes are picked up too.

Worth knowing: a sample is a sample. In a genuinely heterogeneous collection a rare document shape can fall outside the first 100, so a query that depends on it may need a follow-up prompt.

The connection we recommend

MongoDB has no GRANT. Access comes from assigning a built-in role, and the one you want is read.

use admin

db.createUser({
  user: "byesql_reader",
  pwd: "a-strong-password",
  roles: [ { role: "read", db: "your_database_name" } ]
})

The read role covers find, aggregate, count and listing collections and indexes, which is everything ByeSQL needs. Prefer it overreadAnyDatabase, which reaches every database on the deployment.

What reaches your cluster, and what does not

Every generated pipeline is parsed and checked before MongoDB sees it.

Rejected before execution
  • $out and $merge, which write results back into a collection
  • $function, $where and $accumulator, which run arbitrary code on the server
  • $mapReduce
  • Anything that is not a valid pipeline document naming a collection
What actually runs
  • A read-only aggregation pipeline
  • With a trailing $limit added or lowered to the maximum
  • Issued by the read-only user you created
  • Cut off if it is still running after 20 seconds

MongoDB questions

MongoDB has no SQL. How does this work?

You write the same kind of question you would for any other database, and ByeSQL produces an aggregation pipeline instead of a SQL statement. The prompt, the result, the history and the dashboards all behave identically; only the query language underneath changes.

How does it know my fields if there is no schema?

It samples the first 100 documents of each collection and infers the shape: field names including nested paths, the types actually seen, whether a field is missing from some documents, the _id primary key and any unique single-field indexes. A field that appears in only part of the sample is marked as optional rather than assumed.

What if my documents are not uniform?

That is normal and it is handled rather than hidden. When a field holds different types across the sampled documents, every type seen is recorded instead of one being picked. Where a collection is genuinely heterogeneous, the sample may miss a rare shape, which is worth knowing before trusting a query that depends on it.

Can it modify my collections?

No. The pipeline is parsed and rejected if it contains $out, $merge, $function, $where, $accumulator or $mapReduce, which covers both the write stages and the server-side execution operators. A trailing $limit is also forced onto every pipeline: 200 documents by default and 5,000 at most.

See all frequently asked questions →

Ask your MongoDB database a question

Free plan, no credit card. Read-only by default, so production is a safe place to start.