use std::fmt::Debug;
use crate::document::document::BaseDocument;
use crate::document::pageable::{PageableRequest, PageableResponse};
use async_trait::async_trait;
use bson::oid::ObjectId;
use bson::Document;
use mongodb::error::Error;
use mongodb::options::{FindOneOptions, FindOptions};
use mongodb::Database;
use opentelemetry::trace::{Span, Tracer};
use opentelemetry::{global, Context, KeyValue};
#[async_trait]
pub trait Repository<T: BaseDocument + Debug + serde::ser::Serialize + for<'de> serde::Deserialize<'de>> {
async fn save(&self, entity: T, ctx: Option<&Context>) -> Result<ObjectId, Error>;
async fn save_many(
&self,
entities: Vec<T>,
ctx: Option<&Context>,
) -> Result<Vec<ObjectId>, Error>;
async fn get_all_pageable(
&self,
request: PageableRequest,
ctx: Option<&Context>,
) -> Result<PageableResponse<T>, Error>;
async fn count_documents_in_collection(&self, ctx: Option<&Context>) -> Result<u64, Error>;
async fn find_by_id(&self, id: &str, ctx: Option<&Context>) -> Result<T, Error>;
async fn find_by_raw_id(&self, id: ObjectId, ctx: Option<&Context>) -> Result<T, Error>;
async fn find_by_ids(&self, ids: Vec<String>, ctx: Option<&Context>) -> Result<Vec<T>, Error>;
async fn find_by_raw_ids(
&self,
pids: Vec<ObjectId>,
ctx: Option<&Context>,
) -> Result<Vec<T>, Error>;
async fn find_by_filter_and_options(
&self,
filter: Document,
options: Option<FindOneOptions>,
ctx: Option<&Context>,
) -> Result<T, Error>;
async fn find_all_by_filter_and_options(
&self,
filter: Document,
options: Option<FindOptions>,
ctx: Option<&Context>,
) -> Result<Vec<T>, Error>;
async fn update(&self, entity: &T, ctx: Option<&Context>) -> Result<ObjectId, Error>;
async fn delete(&self, pid: String, ctx: Option<&Context>) -> Result<(), Error>;
}