1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use std::collections::{HashMap, VecDeque};
use crate::bson::{Bson, Document};
#[derive(Debug)]
pub struct InsertOneResult {
pub inserted_id: Bson,
}
impl InsertOneResult {
pub(crate) fn from_insert_many_result(result: InsertManyResult) -> Self {
Self {
inserted_id: result
.inserted_ids
.get(&0)
.cloned()
.unwrap_or_else(|| Bson::Null),
}
}
}
#[derive(Debug)]
pub struct InsertManyResult {
pub inserted_ids: HashMap<usize, Bson>,
}
impl InsertManyResult {
pub(crate) fn new() -> Self {
InsertManyResult {
inserted_ids: HashMap::new(),
}
}
}
#[derive(Debug)]
pub struct UpdateResult {
pub matched_count: i64,
pub modified_count: i64,
pub upserted_id: Option<Bson>,
}
#[derive(Debug)]
pub struct DeleteResult {
pub deleted_count: i64,
}
#[derive(Debug, Clone)]
pub(crate) struct GetMoreResult {
pub(crate) batch: VecDeque<Document>,
pub(crate) exhausted: bool,
}