Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Local API: trying to query other collections have a matching relationship field

default discord avatar
brass_monkeelast year

post.docs[0].project is a previous resolved query.



const connectedPostsQuery = await payload.find({
      collection: 'posts',
      where: {
        project: {
          equals: post.docs[0].project,
        },
      },
    })

is is possible to access nested properties with local API?



Figured it out. it was enough to compare "project" directly to


post.docs[0].project.id


since the type was

string | Project

(thank you TypeScript!)


example for the next person:



const connectedPostsQuery = await payload.find({
      collection: 'posts',
      where: {
        project: {
          equals: post.docs[0].project.id,
        },
      },
    })
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.