From 9c15b0a3756c915ab132c8a095c256e12e5862d7 Mon Sep 17 00:00:00 2001 From: Akulij Date: Mon, 26 May 2025 20:15:27 +0500 Subject: [PATCH] create DbCollection and GetCollection traits --- src/db/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/db/mod.rs b/src/db/mod.rs index b703147..1a0715b 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -12,7 +12,7 @@ use futures::stream::TryStreamExt; use mongodb::options::IndexOptions; use mongodb::{bson::doc, options::ClientOptions, Client}; -use mongodb::{Database, IndexModel}; +use mongodb::{Collection, Database, IndexModel}; use serde::{Deserialize, Serialize}; #[derive(EnumStringify)] @@ -193,6 +193,14 @@ impl DB { } } +pub trait DbCollection { + const COLLECTION: &str; +} + +pub trait GetCollection { + async fn get_collection(&mut self) -> Collection; +} + #[async_trait] impl CallDB for DB { async fn get_database(&mut self) -> Database {