Skip to content

Commit

Permalink
Merge branch 'main' into feat/mongo-relationMode-prismaSkipIntegrity
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzSiL3Nce authored Oct 8, 2024
2 parents 2cbb534 + 00f0d73 commit 2dc61d8
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{constants::*, output_meta, query_builder::MongoReadQueryBuilder, val
use connector_interface::*;
use mongodb::{bson::Document, ClientSession, Database};
use query_structure::{prelude::*, Filter, QueryArguments};
use tracing::{info_span, Instrument};

pub async fn aggregate<'conn>(
database: &Database,
Expand All @@ -16,11 +17,17 @@ pub async fn aggregate<'conn>(
let is_group_by = !group_by.is_empty();
let coll = database.collection(model.db_name());

let span = info_span!(
"prisma:engine:db_query",
user_facing = true,
"db.statement" = &format_args!("db.{}.aggregate(*)", coll.name())
);

let query = MongoReadQueryBuilder::from_args(query_arguments)?
.with_groupings(group_by, &selections, having)?
.build()?;

let docs = query.execute(coll, session).await?;
let docs = query.execute(coll, session).instrument(span).await?;

if is_group_by && docs.is_empty() {
Ok(vec![])
Expand Down

0 comments on commit 2dc61d8

Please sign in to comment.