A power-user oriented MongoDB CLI written in Rust, focused on productivity, scripting, and rich output.
Note: This project is an independent, community-driven tool. It is NOT affiliated with MongoDB, and it is not intended to be a drop-in replacement for the official
mongosh.
The official MongoDB Shell (mongosh) is excellent for compatibility and JavaScript workflows. This project exists for engineers who want a faster, more scriptable, and CLI-native experience:
- π§ Power-user workflows β Batch queries, automation, CI/CD
- π Readable output β Tables, highlighted JSON
- β‘ Fast startup & execution β Compiled Rust binary
- π§© Extensible architecture β Plugins & future extensions
If you rely heavily on JavaScript execution inside the shell, you should continue using the official
mongosh.
| Feature | Official mongosh | This Project |
|---|---|---|
| Implementation | Node.js | Rust (async) |
| JS Runtime | Full JavaScript | β Not a JS shell |
| Startup Time | Slower | Fast |
| Output | JSON-first | Tables + highlighted JSON |
| Scripting | JS-based | CLI / batch-oriented |
| Target Users | General users | Power users / DevOps |
β οΈ Active Development β Not Production Ready
- APIs and commands may change
- Some MongoDB features are incomplete
- Bugs and panics may exist
Feedback, testing, and contributions are highly welcome.
- β‘ High Performance β Native Rust, async I/O
- πΎ Lightweight β Small static binary
- π Type Safety β Memory-safe by design
- π§΅ Async Execution β Powered by Tokio
- π¨ Syntax Highlighting β Readable command & JSON output
- π§ Smart Completion β Context-aware auto-completion
- π Rich Output β Table & structured views (WIP)
- π Extensible β Plugin-friendly design
- π Cross-Platform β Linux, macOS, Windows
cargo install mongoshNote: The binary name may change in the future to avoid conflicts with the official MongoDB shell.
# Connect to local MongoDB
mongosh
# Connect to a specific host
mongosh mongodb://localhost:27017
# Connect with authentication
mongosh mongodb://username:password@localhost:27017/dbnameshow dbsuse mydbshow collectionsdb.users.insertOne({ name: "John Doe", age: 25 });db.users.find({ age: { $gte: 18 } });db.users.updateOne({ name: "John Doe" }, { $set: { age: 26 } });db.orders.aggregate([
{ $match: { status: "completed" } },
{ $group: { _id: "$userId", total: { $sum: "$amount" } } },
]);This shell now supports SQL SELECT queries that are automatically translated to MongoDB queries!
-- Simple query with filtering and sorting
SELECT name, age FROM users WHERE age > 18 ORDER BY name ASC
-- Pagination with LIMIT and OFFSET
SELECT * FROM users LIMIT 10 OFFSET 5-- Column aliases support both identifiers and quoted strings
SELECT group_id AS 'group_id', COUNT(*) FROM templates GROUP BY group_id
-- Group by with multiple aggregates
SELECT
category,
COUNT(*) AS total,
SUM(price) AS revenue
FROM products
GROUP BY category- β
SELECT with column list or
* - β FROM clause
- β
WHERE with comparison operators (
=,!=,>,<,>=,<=) - β Logical operators (AND, OR)
- β GROUP BY with aggregation functions (COUNT, SUM, AVG, MIN, MAX)
- β ORDER BY with ASC/DESC
- β LIMIT and OFFSET
- β Column aliases with AS (supports both identifiers and string literals)
| SQL | MongoDB |
|---|---|
SELECT * FROM users |
db.users.find({}) |
SELECT name, age FROM users |
db.users.find({}, {name: 1, age: 1}) |
WHERE age > 18 |
{age: {$gt: 18}} |
WHERE status = 'active' AND age >= 18 |
{$and: [{status: 'active'}, {age: {$gte: 18}}]} |
ORDER BY name ASC |
{name: 1} |
LIMIT 10 |
limit(10) |
GROUP BY category |
aggregate([{$group: {_id: "$category"}}]) |
SELECT COUNT(*) FROM users |
aggregate([{$group: {_id: null, COUNT_*: {$sum: 1}}}]) |
- SQL queries are automatically detected when starting with
SELECT - Complex JOIN operations are not yet supported
- Subqueries are not yet supported
Licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
If you have any questions, suggestions, or issues, please open an issue on GitHub.