# Rust MongoDB Power CLI
[](https://crates.io/crates/mongosh)
[](https://www.rust-lang.org)
[](https://opensource.org/licenses/MIT)
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`.
---
## โจ Why Another MongoDB CLI?
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`.
---
## ๐ Key Differences vs Official mongosh
| 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 |
---
## ๐ง Project Status
> โ ๏ธ **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.
---
## โจ Features
- โก **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
---
## ๐ฆ Installation
```bash
cargo install mongosh
```
> **Note:** The binary name may change in the future to avoid conflicts with the official MongoDB shell.
---
## ๐ Quick Start
### Connect to MongoDB
```bash
# Connect to local MongoDB
mongosh
# Connect to a specific host
mongosh mongodb://localhost:27017
# Connect with authentication
mongosh mongodb://username:password@localhost:27017/dbname
```
---
## ๐งช Example Commands
### Show Databases
```javascript
show dbs
```
### Switch Database
```javascript
use mydb
```
### Show Collections
```javascript
show collections
```
### Insert a Document
```javascript
db.users.insertOne({ name: "John Doe", age: 25 });
```
### Query Documents
```javascript
db.users.find({ age: { $gte: 18 } });
```
### Update Documents
```javascript
db.users.updateOne({ name: "John Doe" }, { $set: { age: 26 } });
```
### Aggregation Pipeline
```javascript
db.orders.aggregate([
{ $match: { status: "completed" } },
{ $group: { _id: "$userId", total: { $sum: "$amount" } } },
]);
```
---
## ๐ License
Licensed under the [MIT License](https://opensource.org/licenses/MIT).
---
## ๐ค 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.