107 releases (7 stable)

3.7.0 Jun 13, 2026
3.2.2 Aug 26, 2025
3.2.1 Jun 29, 2025
3.2.0 Feb 12, 2025
0.0.11 Nov 19, 2021

#576 in Encoding

Download history 57/week @ 2026-04-16 52/week @ 2026-04-23 59/week @ 2026-04-30 72/week @ 2026-05-07 47/week @ 2026-05-14 37/week @ 2026-05-21 56/week @ 2026-05-28 40/week @ 2026-06-04 41/week @ 2026-06-11 50/week @ 2026-06-18 19/week @ 2026-06-25 141/week @ 2026-07-02 143/week @ 2026-07-09 118/week @ 2026-07-16 79/week @ 2026-07-23 378/week @ 2026-07-30

738 downloads per month
Used in 2 crates

MIT license

23KB
586 lines

mungos

inspired by the mongoose npm package, this crate contains the Mungos struct, a wrapper around the mongodb client containing some additional queries and functionality

usage

#[derive(Serialize, Deserialize, Debug)]
struct TestDoc {
	timestamp: i64,
	name: String,
	#[serde(default)]
	description: String,
}

let mungos = mungos::Mungos::new(uri, app_name, Duration::from_secs(3), None).await.unwrap();
let coll = mungos.collection::<TestDoc>("test_db", "test_coll");

let items: Vec<TestDoc> = coll
	.get_most_recent(
		"timestamp", 
		10, 
		0, 
		None, 
		mungos::Projection("timestamp name")
	)
	.await
	.unwrap();

println!("{items:#?}"); // prints the 10 most recent docs by timestamp

initializing from environment

# specify full uri directly
MONGO_URI=mongodb://username:password@localhost:27017

## or

# specify uri parts
MONGO_ADDRESS=localhost:27017
MONGO_USERNAME=username
MONGO_PASSWORD=password

# ---------------------

# specify other options
MONGO_APP_NAME=tester # optional. default is 'mungos'
MONGO_TIMEOUT_SECS=30 # optional. default is '3'
MONGO_COMPRESSORS=snappy,zstd(10),zlib(8) # optional. defaults to None
let mungos = mungos::Mungos::new_from_env().await.unwrap();
let coll = mungos.collection::<TestDoc>("test_db", "test_coll");

let items = coll.get_some(None, None).await.unwrap(); // Vec<TestDoc>

Dependencies

~11–15MB
~288K SLoC