DB Helper
MongoDB aggregation pipeline & PostgreSQL IntelliSense, hover docs, auto-formatting,
CodeLens actions, and a built-in connection runner — for TypeScript, JavaScript, and Python.
Features at a glance
|
Feature |
| 🧠 |
IntelliSense — stage & operator completions for MongoDB pipelines; keyword, function & type completions for SQL |
| 📖 |
Hover docs — inline documentation for every $stage and $operator |
| ✨ |
Auto-formatting — pipelines expand to readable multi-line notation; SQL is normalized with configurable casing and indentation |
| ▶ |
CodeLens toolbar — Format · Copy · Run · Open Docs · Ask AI above every tagged block |
| ⚡ |
Run queries — execute a pipeline via mongosh or a SQL query via pg and see results in a syntax-highlighted editor tab |
| ⚙️ |
Settings sidebar — configure connections, enable/disable per language, and adjust markers from the Activity Bar |
Features
MongoDB aggregate pipeline IntelliSense
Tag any array literal with /*mongo-pipeline*/ (TypeScript/JavaScript) or # mongo-pipeline (Python) and the extension activates full IntelliSense inside it:
- Stage completions —
$match, $group, $lookup, $project, $sort, $limit, $unwind, $addFields, $facet, $vectorSearch, and 20+ more, each with snippet templates.
- Operator completions —
$eq, $in, $sum, $avg, $push, $cond, $dateToString, and dozens more — context-aware based on the enclosing stage.
- Hover documentation — hover over any
$stage or $operator to read its description and usage notes.
- Auto-formatting — the pipeline is expanded to readable multi-line JS-style notation (unquoted keys, proper indentation).
// TypeScript / JavaScript
const pipeline = /*mongo-pipeline*/[
{ $match: { status: 'active' } },
{ $group: { _id: '$dept', total: { $sum: '$salary' } } },
{ $sort: { total: -1 } },
];
# Python
pipeline = [ # mongo-pipeline
{"$match": {"status": "active"}},
{"$group": {"_id": "$dept", "total": {"$sum": "$salary"}}},
]
PostgreSQL / SQL IntelliSense
Tag a string with the SQL marker and the extension activates keyword completions and auto-formatting inside it.
TypeScript / JavaScript — use a template literal or regular string prefixed with /*sql*/:
const query = /*sql*/`
SELECT u.id, u.name, COUNT(o.id) AS order_count
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id
ORDER BY order_count DESC
`;
Python — use a triple-quoted or single-quoted string whose first line starts with --sql:
query = """--sql
SELECT u.id, u.name, COUNT(o.id) AS order_count
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id
ORDER BY order_count DESC
"""
SQL completions include all PostgreSQL keywords, functions, data types, and common clause templates with snippet placeholders.
Pipelines and SQL strings are formatted in three ways:
| Trigger |
Behaviour |
| Auto-format while typing |
After you stop typing for 4 seconds (configurable), every pipeline and SQL string in the file is automatically formatted. |
| Format on save |
When you save the file all pipelines and SQL strings are formatted (enabled by default). |
| Command palette |
Run DB Helper: Format MongoDB Pipeline or DB Helper: Format SQL Query at any time. |
Extension Settings
Open Settings (Ctrl+, / Cmd+,) and search for DB Helper, or edit settings.json directly.
| Setting |
Type |
Default |
Description |
dbHelper.mongo.enable |
boolean |
true |
Enable MongoDB pipeline IntelliSense and formatting. |
dbHelper.postgres.enable |
boolean |
true |
Enable SQL IntelliSense and formatting. |
dbHelper.mongo.marker |
string |
/*mongo-pipeline*/ |
Comment tag before [ that marks a MongoDB pipeline in TypeScript/JavaScript. |
dbHelper.mongo.pyMarker |
string |
# mongo-pipeline |
Trailing comment after [ that marks a MongoDB pipeline in Python (e.g. pipeline = [ # mongo-pipeline). |
dbHelper.sql.marker |
string |
/*sql*/ |
Comment tag that marks a SQL string in TypeScript/JavaScript. |
dbHelper.sql.pyMarker |
string |
--sql |
Prefix that marks a SQL string in Python. |
dbHelper.sql.tabWidth |
number |
4 |
Tab width used when formatting SQL. |
dbHelper.sql.keywordCase |
"upper" | "lower" | "preserve" |
"upper" |
Keyword casing in formatted SQL output. |
dbHelper.formatOnSave |
boolean |
true |
Format pipelines and SQL strings on file save. |
dbHelper.formatDelay |
number |
4000 |
Milliseconds after the last keystroke before auto-formatting while typing. Set to 0 to disable. |
Changing the markers
If you prefer a different tag — for example /*pipeline*/ for MongoDB or --postgres for Python SQL — just update the settings:
// settings.json
{
"dbHelper.mongo.marker": "/*pipeline*/",
"dbHelper.sql.marker": "/*postgres*/",
"dbHelper.sql.pyMarker": "--postgres"
}
Then use your chosen tag in source files and IntelliSense + formatting will follow.
Commands
| Command |
Title |
db-helper.formatMongoPipeline |
DB Helper: Format MongoDB Pipeline |
db-helper.formatSQL |
DB Helper: Format SQL Query |
Access them via the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
Supported Languages
TypeScript, JavaScript, and Python.
Release Notes
0.1.0
Initial release — MongoDB pipeline IntelliSense, hover docs, formatting; PostgreSQL SQL IntelliSense and formatting; configurable markers; auto-format on type with debounce delay.