-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDB findRaw filter problem with ObjectId field. #11830
Comments
Thanks @casperibo, I've confirmed this bug. Reproduction: https://github.com/matthewmueller/prisma-issue-11830 |
Hi @matthewmueller thank you for your interest. I tried a few things like you said but unfortunately it didn't work. I try to filter from MongoDb Atlas filter area and I got the result that I want.
The schema looks like same but I saw your repository that you share, and the version doesn't have same version like my project. Is there any way you to try in version 3.9.2. or Is there something I can do. My Schema fields:
|
Hey @casperibo, since ids are represented with const users = await prisma.user.findRaw({
filter: {
_id: { $eq: { $oid: "6202ec178be26d2b28adc075" } },
},
}) |
Hi @millsp It's helped a lot thank you. I solved my problem. I would like to ask more question though. When I use findRaw method to get datas, the object ids coming like;
And it's causes a problem on graphql like "non nullable field id not found" something like that. Do you have any solution for that problem? |
You're welcome :) Right now, I don't see any quick solution to that problem. The easiest would be for you to use middlewares to transform the returned objects to the shape you need https://www.prisma.io/docs/concepts/components/prisma-client/middleware. |
(If you do, please share the resulting Middleware - others might benefit from it as well.) |
unable to do limit and skip in findRaw, not working |
Bug description
Hi, I try to get items by its categories using findRaw method but I couldn't.
I think it's a type problem, I should write like ObjectId("categoryId");
I installed mongodb and try to use;
const catId = new ObjectId(categoryId);
$categoryId: { $eq: catId }
But It didn't work.
How to reproduce
Expected behavior
Filter items which has defined categoryId.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: