Noql
Converts SQL queries into MongoDB queries or aggregation pipelines
Install / Use
/learn @synatic/NoqlREADME
NoQL - Not Only SQL
NoQL Converts SQL statements to Mongo find statements or aggregation pipelines. NoQL supports mySQL and Postgres Syntax, and generates Mongo 3.6 or greater compatible queries.
For full docs and a playground to try NoQL out, visit https://noql.synatic.dev/
Installation
Install NoQL using the npm install command:
npm i @synatic/noql
Usage
NoQL outputs an object with the type, either query or aggregate, along with the components of the Mongo query. To use the output object, construct a query with MongoClient from the MongoDB NodeJS Driver:
const SQLParser = require('@synatic/noql');
const {MongoClient} = require('mongodb');
(async () => {
try {
client = new MongoClient('mongodb://127.0.0.1:27017');
await client.connect();
const db = client.db('noql-test');
const parsedSQL = SQLParser.parseSQL('select id from `films` limit 10');
if (parsedSQL.type === 'query') {
console.log(
await db
.collection(parsedSQL.collection)
.find(parsedSQL.query || {}, parsedSQL.projection || {})
.limit(parsedSQL.limit || 50)
.toArray()
);
} else if (parsedSQL.type === 'aggregate') {
console.log(
await db
.collection(parsedSQL.collections[0])
.aggregate(parsedSQL.pipeline)
.toArray()
);
}
} catch (exp) {
console.error(exp);
}
})();
NoQL Output Examples
NoQL outputs an object with the type, either query or aggregate, along with the components of the Mongo query. Here are some examples of the output:
For a straight query:
SQLMongoParser.parseSQL('select id from `films` where `id` > 10 limit 10');
NoQL will output:
{
"limit": 10,
"collection": "films",
"projection": {
"id": "$id"
},
"query": {
"id": {
"$gt": 10
}
},
"type": "query"
}
For an aggregate query:
SQLMongoParser.makeMongoAggregate(
'select id from `films` where `id` > 10 group by id'
);
NoQL will output:
{
"pipeline": [
{
"$match": {
"id": {
"$gt": 10
}
}
},
{
"$group": {
"_id": {
"id": "$id"
}
}
},
{
"$project": {
"id": "$_id.id",
"_id": 0
}
}
],
"collections": ["films"]
}
Currently Unsupported SQL Statements
- Over
- CTE's
- Pivot
- Union
See more in the full docs at https://noql.synatic.dev/
Related Skills
oracle
353.3kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
353.3kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
111.7kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
111.7kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
