framework_cqrs_lib/cqrs/infra/query/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use mongodb::bson::{doc, Document};

use crate::cqrs::core::repositories::filter::Expr::ExprStr;
use crate::cqrs::core::repositories::filter::Filter;
use crate::cqrs::core::repositories::filter::Filter::Expr;
use crate::cqrs::core::repositories::query::Query;

pub mod pagination;

impl From<Query> for Document {
    fn from(value: Query) -> Self {
        match value.filter {
            Expr(e) => {
                match e {
                    ExprStr(x) => doc! { x.field.as_str() : x.head.as_str() }
                }
            }
            Filter::None => doc! {}
        }
    }
}