Expand description
MongoDB Shell Library
This library provides the core functionality for the MongoDB Shell (mongosh) implementation. It can be used as a standalone library to build MongoDB tools and applications.
§Modules
cli: Command-line interface and argument parsingconfig: Configuration managementconnection: MongoDB connection managementerror: Error types and handlingexecutor: Command execution engineformatter: Output formatting and displayparser: Command and query parsingplugins: Plugin system for extensibilityrepl: Interactive REPL engine
§Example
use mongosh::{config::Config, connection::ConnectionManager};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::default();
let mut manager = ConnectionManager::new(
"mongodb://localhost:27017".to_string(),
config.connection,
);
manager.connect().await?;
println!("Connected to MongoDB");
manager.disconnect().await?;
Ok(())
}Re-exports§
pub use config::Config;pub use connection::ConnectionManager;pub use error::MongoshError;pub use error::Result;pub use executor::CommandRouter;pub use executor::ExecutionResult;pub use formatter::Formatter;pub use parser::Command;pub use parser::Parser;pub use repl::ReplEngine;
Modules§
- cli
- Command-line interface for mongosh
- config
- Configuration management for mongosh
- connection
- Connection management for MongoDB
- error
- Error handling module for MongoDB operations.
- executor
- Command execution engine for mongosh
- formatter
- Output formatting and colorization for mongosh
- parser
- Command and query parser for mongosh
- repl
- REPL (Read-Eval-Print Loop) module root for mongosh
Constants§
- VERSION
- Library version
Functions§
- version
- Get library version string