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.

QueryError when trying to filter results

default discord avatar
dhzdhdlast year
2
GET http://127.0.0.1:3002/api/fees

works fine and returns all the fees collection results but

GET http://127.0.0.1:3002/api/fees?where[student.value.number][equals]=10

or

GET http://127.0.0.1:3002/api/fees?where[student.number][equals]=10

results in a QueryError



fee collection fields -


fields: [
    { name: "description", type: "text", required: true },
    { name: "amount", type: "number", required: true },
    { name: "dueDate", label: "Due date", type: "date", required: true },
    {
      name: "paymentStatus",
      label: "Payment status",
      type: "select",
      options: ["paid", "unpaid", "delayed"],
      defaultValue: "unpaid",
      required: true,
    },
    {
      name: "student",
      type: "relationship",
      relationTo: ["students"],
      hasMany: false,
      required: true,
    },
  ],


example result from general fetch


{
    "docs": [
        {
            "id": "e33d9a6f-0a77-4d3c-aac8-16307732a132",
            "description": "Initial",
            "amount": 100000,
            "dueDate": "2024-05-28T11:30:00.000Z",
            "paymentStatus": "paid",
            "student": {
                "relationTo": "students",
                "value": {
                    "id": "26e9dbea-7eaa-4e18-b36c-138e1a4432ac",
                    "studentId": 100,
                    "number": 10,
                    "dob": "2024-05-27T11:30:00.000Z",
...


The error-


{
  "errors": [
    {
      "name": "QueryError",
      "data": [
        {
          "path": ""
        }
      ],
      "message": "The following path cannot be queried: "
    }
  ]
}


I am using postgres as the database



Bump

  • default discord avatar
    minsomailast year
    where[student.value.number]

    this works ^ but you have to follow this



    https://payloadcms.com/docs/fields/relationship

    Example:



    /api/trips?where[owner.email][equals]=tripOwnerEmail@gmail.com&limit=1&page=2


    schema def:



        {
          name: "owner",
          type: "relationship",
          relationTo: "users",
          hasMany: false,
          required: true,
        }
  • default discord avatar
    dhzdhdlast year

    oh i see



    thanks

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.