From 581998cec1cc8e39bea924fbeb68ef9b65b50e36 Mon Sep 17 00:00:00 2001 From: Shahriar Shojib Date: Fri, 6 Dec 2024 02:51:38 +0600 Subject: [PATCH] Added mongodb aggregateRaw caveats (#6499) * Added mongodb aggregateRaw caveats * Update content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx Co-authored-by: Jon Harrell <4829245+jharrell@users.noreply.github.com> --------- Co-authored-by: Jon Harrell <4829245+jharrell@users.noreply.github.com> --- .../150-using-raw-sql/200-raw-queries.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx index d9f95702b4..e0ff6126d1 100644 --- a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx +++ b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx @@ -851,3 +851,17 @@ const result = await prisma.user.aggregateRaw({ - `pipeline`: An array of aggregation stages to process and transform the document stream via the [aggregation pipeline](https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline). - `options`: Additional options to pass to the [`aggregate` command](https://www.mongodb.com/docs/manual/reference/command/aggregate/#command-fields). + +#### Caveats + +When working with custom objects like `ObjectId` or `Date,` you will have to pass them according to the [MongoDB extended JSON Spec](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/#type-representations). +Example: +```ts no-lines +const result = await prisma.user.aggregateRaw({ + pipeline: [ + { $match: { _id: { $oid: id } } } +// ^ notice the $oid convention here + ], +}); + +```