Skip to content

Commit

Permalink
Added mongodb aggregateRaw caveats
Browse files Browse the repository at this point in the history
  • Loading branch information
shahriar-shojib authored Dec 5, 2024
1 parent b3cea70 commit adb4a4c
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,18 @@ 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).

:::info
#### 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
],
});

```

0 comments on commit adb4a4c

Please sign in to comment.