mongo_drop
A Rust library providing an RAII-style guard for MongoDB databases, designed for testing environments. It automatically rolls back changes made to the database within the guard's asynchronous scope using MongoDB change streams and the experimental AsyncDrop trait.
🚨 WARNING: This crate relies on the experimental async_drop feature, which is only available on nightly Rust and is subject to change or removal. It is NOT suitable for production use. Use this crate for test helpers or experimentation only.
Usage
Features
-
tracing: Enables tracing support for the library. -
Automatic Rollback: Leverages
AsyncDropto undo database changes automatically when the guard goes out of scope in anasyncfunction. -
Change Stream Based: Listens to MongoDB change streams to capture modification events.
-
Supports DML Rollback: Undoes
Insert,Update,Delete, andReplaceoperations using collected pre-images. -
Test-Focused: Designed to simplify database state management in integration tests.
Requirements
- Nightly Rust Toolchain: You must use a nightly build of the Rust compiler (
rustup toolchain install nightly).