Local API: query nested property of nested property

default discord avatar
linobino1
7 months ago

I have a collection

screenings

with a relationship to

movies

that has a relationship to

directors

.


Is it possible to get all

screenings

with a movie by a certain

director

?



payload.find({
  collection: 'screenings',
  where: {
    'movie.director': {
      equals: '602c3c327b811235943ee12b,
    },
  },
})


I get this error:


QueryError: The following path cannot be queried: director
    at new ExtendableError (/app/node_modules/payload/src/errors/APIError.ts:26:11)
    at new APIError (/app/node_modules/payload/src/errors/APIError.ts:43:5)
    at new QueryError (/app/node_modules/payload/src/errors/QueryError.ts:8:5)
    at Function.buildQuery (/app/node_modules/payload/src/mongoose/buildQuery.ts:570:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /app/node_modules/payload/src/mongoose/buildQuery.ts:265:30
    at async ParamParser.buildSearchParam (/app/node_modules/payload/src/mongoose/buildQuery.ts:257:35)
    at async ParamParser.parsePathOrRelation (/app/node_modules/payload/src/mongoose/buildQuery.ts:144:35)
    at async ParamParser.parse (/app/node_modules/payload/src/mongoose/buildQuery.ts:117:21)
    at async Function.buildQuery (/app/node_modules/payload/src/mongoose/buildQuery.ts:567:22)


Local API: query nested property of nested property



I opened a github issue now:

https://github.com/payloadcms/payload/issues/2611
    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.