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.

How to query for specific field value in array?

default discord avatar
christian-reichart10 months ago
1 1

So let's say my collection looks something like this:

interface MyCollection {
  myArray: {
    myNumberField: number;
    id?: string;
  }[]
}

I want to get all documents where myNumberField contains a number of [1,2,3]. How would the where query look here? I can't seem to find a solution on https://payloadcms.com/docs/queries/overview#operators

  • Selected Answer
    default discord avatar
    christian-reichart9 months ago

    got it to work, if anyone needs this later:

    where: {
      'myArray.myNumberField': {
        in: [1,2,3]
      }
    }
    
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..