use std::collections::{HashMap, VecDeque};
use crate::bson::{Bson, Document};
use serde::Serialize;
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
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, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct InsertManyResult {
pub inserted_ids: HashMap<usize, Bson>,
}
impl InsertManyResult {
pub(crate) fn new() -> Self {
InsertManyResult {
inserted_ids: HashMap::new(),
}
}
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct UpdateResult {
pub matched_count: i64,
pub modified_count: i64,
pub upserted_id: Option<Bson>,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct DeleteResult {
pub deleted_count: i64,
}
#[derive(Debug, Clone)]
pub(crate) struct GetMoreResult {
pub(crate) batch: VecDeque<Document>,
pub(crate) exhausted: bool,
}