mongo-embedded
A Rust library that simplifies using MongoDB for local testing and development by automatically downloading, extracting, and running a MongoDB Community Edition binary.
It handles:
- OS/Arch Detection: Automatically selects the correct binary for Linux, macOS, and Windows.
- Downloading: Fetches the binary from the official MongoDB download center.
- Extraction: Unpacks
.tgzor.ziparchives. - Execution: Starts the
mongodprocess on a specified port.
Usage
Installation
Run the following command in your project directory:
Or add the following to your Cargo.toml:
[]
= "0.1.1"
= { = "1.0", = ["full"] } # Required for the example below
Example
use MongoEmbedded;
use ;
async
Configuration
The library uses the directories crate to find suitable locations for:
- Cache: Stores downloaded archives (e.g.,
~/.cache/mongo-embeddedon Linux). - Data: Stores the database files (e.g.,
~/.local/share/mongo-embeddedon Linux).
License
MIT