loopbackio / loopbackio/loopback-next

Rest filter is not working properly

Open
#8,366 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Describe the bug

Query parameters sent by rest:
Captura de pantalla de 2022-03-03 11-20-25

Parameters received by LoopBack:

{
  "offset": 0,
  "limit": 10,
  "include": [
    "images"
  ],
  "where": {
    "attributes": {
      "or": [
        {
          "and": {
            "[0][key]": "COLECCIÓN",
            "[0][value]": "100% MARVEL",
            "[1][key]": "MATERIA",
            "[1][value]": "MARVEL"
          }
        }
      ]
    }
  }
}

Parameters expected by LoopBack:

{
  "offset": 0,
  "limit": 10,
  "include": [
    "images"
  ],
  "where": {
    "attributes": {
      "or": [
        {
          "and": [
            { "key": "COLECCIÓN", "value": "100% MARVEL" },
            { "key": "MATERIA", "value": "MARVEL" }
          ]
        }
      ]
    }
  }
}

Therefore the functionality described in the documentation does not work.

Logs

No response

Additional information

No response

Reproduction

N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked LoopBack Where filter documentation and trace how REST query parameters become the shown where.attributes structure. Compare the received object with the expected array form, then verify the documented query against a reproducible REST request. Done means the request produces the expected filter structure and the documented functionality works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.