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