use mongors::*; use bsonrs::doc; fn main() { let client = Mongo::new("mongodb://localhost:27017/").unwrap(); // statuc let cmd = doc!{ "serverStatus": 1 }; let _reply = client.command_simple("admin", cmd, None); //println!("{:?}", _reply); // open collection let db = client.db("test"); let collection = db.collection("test"); let session = client.start_session(None).unwrap(); session.start_transaction(None).unwrap(); println!("{:?}", session.in_transaction()); println!("{:?}", session.lsid()); println!("{:?}", session.cluster_time()); println!("{:?}", session.operation_time()); let session_id = session.session_id().unwrap(); let mut find_option = mongors::collection::FindOptions::new(); find_option.session_id = Some(session_id); let doc = collection.find_one(doc!{}, Some(find_option), None).unwrap(); println!("{:?}", doc); let mut insert_option = mongors::collection::InsertOptions::new(); insert_option.session_id = Some(session_id); let doc = doc!{ "id": 123 }; let result = collection.insert_one(doc, Some(insert_option)); println!("{:?}", result); let r = session.commit_transaction(); println!("{:?}", r); }