use collection.load(rx) for writer task

This commit is contained in:
Dmitry Belyaev 2022-10-10 16:15:16 +03:00
parent 2acb324da9
commit 5ed8c12f91
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -102,13 +102,9 @@ fn db_writer_task(rx: mpsc::Receiver<Question>) {
let storage = Storage::new(DB_DIR, options).unwrap();
let collection = storage.collection("questions").unwrap();
let mut count: usize = 0;
rx.into_iter().for_each(|question| {
collection.insert(question).expect("insert question");
count += 1;
});
let count = collection.load(rx).expect("load");
println!("inserted {count}");
println!("loaded {count}");
println!("syncing to disk...");
storage.sync(true).unwrap();