Please help me this time, when I raw aggregate que...
# orm-help
p
Please help me this time, when I raw aggregate query against mongodb atlas for objectId, I get error about ObjectIt Type. "Remote error from mongot :: caused by :: \"compound.must[1].equals.value\" must be a boolean or objectId)"" Here is my query
Copy code
await prisma.userAgent.aggregateRaw({
    pipeline: [
      {
        $search: {
          compound: {
            must: [
              {
                text: {
                  query: "opera",
                  path: {
                    wildcard: "*",
                  },
                },
              },
              {
                equals: {
                  path: "application_id",
                  value: 'ObjectId("6284913de2e5beb0e6336033")',
                },
              },
            ],
          },
        },
      },
    ],
  });
For the value field, I tried 'ObjectId("6284913de2e5beb0e6336033")', new ObjectID("id"), "6284913de2e5beb0e6336033", etc... All fails with the same error message. How do I pass ObjectId to mongodb atlas using aggregateRaw????
r
Hi @prisma chobo - I see this example in the docs, maybe it can help:
Copy code
const newId1 = new ObjectId()
const newId2 = new ObjectId()

const posts = await prisma.post.findMany({
  where: {
    categoryIDs: {
      hasSome: [newId1.toHexString(), newId2.toHexString()],
    },
  },
})
so maybe:
Copy code
{
                equals: {
                  path: "application_id",
                  value: ObjectId("6284913de2e5beb0e6336033").toHexString(),
                },
?
Sorry - I missed the "aggregrateRaw" piece ..
p
Turns out that I had to use
Copy code
value: {
                    $oid: "6284913de2e5beb0e6336033",
                  }
n
Thanks for reporting this, it seems we could document this use case better, I’ll pass the feedback 👍