We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6f9ca9b commit 39435e2Copy full SHA for 39435e2
1 file changed
src/storage.rs
@@ -29,17 +29,13 @@ impl<'a> Store<'a> {
29
const DUPLICATE_KEY_ERROR_CODE: i32 = 11000;
30
match collection.insert_many(batch).ordered(false).run() {
31
Ok(_) => Ok(()),
32
- Err(e)
33
- if matches!(
34
- e.kind.as_ref(),
35
- mongodb::error::ErrorKind::BulkWrite(f)
36
- if f.write_concern_errors.is_empty()
37
- && f.write_errors.values().all(|b| b.code == DUPLICATE_KEY_ERROR_CODE)
38
- ) =>
39
- {
40
- Ok(())
41
- }
42
- Err(e) => Err(anyhow!(e)),
+ Err(e) => match e.kind.as_ref() {
+ mongodb::error::ErrorKind::InsertMany(mongodb::error::InsertManyError {
+ write_errors: Some(errors),
+ ..
+ }) if errors.iter().all(|b| b.code == DUPLICATE_KEY_ERROR_CODE) => Ok(()),
+ _ => Err(anyhow!(e)),
+ },
43
}
44
45
0 commit comments