docs.rs failed to build mongosh-0.7.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
mongosh-0.9.0
Rust MongoDB Power CLI
A powerful MongoDB CLI written in Rust, featuring intelligent auto-completion, SQL query support, and enhanced security features for productive database operations.
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.
๐ Key Differences vs 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 |
โจ Features
- โก High Performance โ Native Rust, async I/O
- ๐พ Lightweight โ Small static binary
- ๐จ Syntax Highlighting โ Readable command & JSON output
- ๐ Rich Output Formats โ JSON (pretty/compact), shell-style, and table views
- ๐๏ธ SQL Query Support โ Query MongoDB using familiar SQL SELECT syntax
- ๐ง Intelligent Auto-Completion โ Context-aware suggestions for MongoDB shell and SQL commands
๐ฆ Installation
Note: The binary name may change in the future to avoid conflicts with the official MongoDB shell.
๐ Quick Start
Connect to MongoDB
# Connect to local MongoDB
# Connect to a specific host
# Connect with authentication (credentials are automatically sanitized in logs)
๐งช Example Commands
// Show Databases
show dbs
// Switch Database
use mydb
// Show Collections
show collections
// Insert a Document
db..;
// Query Documents
db..;
// Update Documents
db..;
// Aggregation Pipeline
db..;
๐ SQL Query Support
This shell now supports SQL SELECT queries that are automatically translated to MongoDB queries!
Basic SELECT 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
Aggregate Functions
-- 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
Supported SQL Features
- โ
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 to MongoDB Translation Examples
| 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}}}]) |
Notes
- SQL queries are automatically detected when starting with
SELECT - Complex JOIN operations are not yet supported
- Subqueries are not yet supported
๐ License
Licensed under the MIT License.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ฌ Feedback
If you have any questions, suggestions, or issues, please open an issue on GitHub.