Martin Häusler
Martin Häusler

Reputation: 7284

Is there a grammar definition (e.g. EBNF) for MongoDB queries?

I would like to build a tool that involves parsing a MongoDB query AST from an input string. However, I've been unable to find any comprehensive grammar definition on the web.

There's mnogodb-language-model for example, but it is very outdated. It's grammar doesn't support unquoted expressions or regular expressions (in /.../ notation), and its AST doesn't seem to include anything inside an $expr filter.

I would be happy with any up-to-date comprehensive description, (E)BNF, pegJS, ANTLR, etc. Does anybody know where I might find something like that? If it happens to include the aggregation pipeline syntax, that would be even better.

Upvotes: 5

Views: 410

Answers (0)

Related Questions