use collection.load(rx) for writer task
This commit is contained in:
parent
2acb324da9
commit
5ed8c12f91
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user