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.

Where clause for Array

default discord avatar
gammasenninlast year

Dear community



I'm struggling to build a where clause for local api that querries an array.



I have an array field, containing references that looks like following



{
      type: 'array',
      name: 'conversationTexts',
      label: 'Conversation Texts',
      fields: [
        {
          type: 'relationship',
          name: 'text',
          label: 'Conversation Text',
          relationTo: ConversationTexts.slug,
          required: true,
        },
      ],
    },


Now I want to query on local api if I have a specific element within the array that fulfils something like this:

conversationTexts: { contains : { text: { equals: idToCheck }}}

But it looks like that query is crap.


So does someone know how a correct document query with a search for a payload array object looks like?



Ok looks like its just a

.

concatenation.



conversationTexts.text: {
      "equals": "idToCheck"
    }


Which I find strange for an array, but ok if it works.

    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.