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.

Query by nested object does not work

default discord avatar
ivandominguezdomilast year
5

Hello

@everyone

!



I am trying to do a rest api query on a collection using a nested object attribute



/api/tickets?where[order.orderId][equeals]=1363580640437-01


Tickets has this structure


fields: [
        {
            name: 'order',
            label: 'Order',
            type: 'relationship',
            relationTo: 'orders',
            required: true,
            unique: true,
        }
    ],

And orders:


    fields: [
        {
            name: 'orderId',
            type: 'text',
            required: true,
            label: 'ID de Pedido',
        }
              ]
  • discord user avatar
    tylandavis
    last year

    Hi

    @934105872794267648

    , it looks like you have a typo in your query.

    [equeals]

    should be

    [equals]
  • default discord avatar
    ivandominguezdomilast year

    Sorry, it was my mistake when making the post, but in my tests I put

    equals

    and it does not work.

  • discord user avatar
    tylandavis
    last year

    okay, let me take a closer look

  • default discord avatar
    ivandominguezdomilast year

    thank you very much, do you need more information?

  • discord user avatar
    tylandavis
    last year

    Okay I got it. For nested query strings, instead of using dot notation, use bracket notation.



    So, instead of

    [order.orderId]

    , use

    [order][orderId]
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.