Aggregate Raw not working when trying to `$match` on `_id` (needs to be an `ObjectId` but it's not a valid input)
See original GitHub issuenew aggregate raw support
@matthewmueller Do you guys know about any issue that the raw aggregation support is having? I’m trying to run a pipeline though it, which I know for a fact that is working because I wrote it and tested it at first on MongoDB Compass.
return this.prisma.user.aggregateRaw({
pipeline: [
{
$match: {
_id: id,
},
},
{
$project: {
communityId: 1,
},
},
{
$lookup: {
from: 'Community',
localField: 'communityId',
foreignField: '_id',
as: 'community',
},
},
{
$project: {
communityId: 0,
},
},
{
$unwind: {
path: '$community',
},
},
{
$lookup: {
from: 'CommunityNft',
localField: 'community._id',
foreignField: 'communityId',
as: 'communityNft',
},
},
{
$unwind: {
path: '$communityNft',
},
},
{
$lookup: {
from: 'NftBenefit',
localField: 'communityNft._id',
foreignField: 'communityNftId',
as: 'nftBenefits',
},
},
{
$lookup: {
from: 'Voucher',
localField: 'nftBenefits._id',
foreignField: 'nftBenefitId',
as: 'vouchers',
},
},
],
});
This operation is returning an empty array.
_Originally posted by @pedrobrun in https://github.com/prisma/prisma/issues/6712#issuecomment-1227771299_
Issue Analytics
- State:
- Created a year ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Aggregate $match _id $eq $toObjectId not working - MongoDB
Using Compass 1.30.1, I was testing an aggregation and getting unexpected results. A $match was not working as expected.
Read more >MongoDB, Aggregate $match not working on ObjectId
I want to filter and get the photo which belong to 1 specific user, based on their user_id. I don't understand what I...
Read more >Raw database access (Reference) - Prisma
Learn how you can send raw SQL and MongoDB queries to your database using the raw() methods from the Prisma Client API.
Read more >Troubleshoot your embedded application - Power BI
This article discusses some common issues you may encounter when embedding content from Power BI.
Read more >JavaScript Developers Guide | Parse
If you want to retrieve objects that do not match any of several values you can ... in Mongo Aggregate Documentation will work...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately no news, I’m not part of the team that will work on this. I can only say it’s on their radar, so they will pick this up one day, but they have to prioritize with other issues.
@Jolg42 ok, got it! Thanks for the update 😃 Prisma’s version was
4.2.1
. Mongo’s locally installed version is5.0.7
, but the development db is hosted on Atlas. Tbh there’s no additional information. I had to migrate to Mongoose as I had some deadlines close and this was a core feature and I didn’t want to have to hit 4+ collections separately. Once this is sorted out I’ll probably move back to Prisma though.