loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.97k stars 1.07k forks source link

Filter by the concatenation of two columns #6840

Open A-Corregidor opened 4 years ago

A-Corregidor commented 4 years ago

Suggestion

It would be nice to be able to filter a Model by the concatenation of two columns. I mean, to be able to replicate this type of SQL query:

SELECT * FROM User WHERE CONCAT(name, ' ', lastName) LIKE '%PARTIAL FULLNAME%'

Use Cases

The most common example is filtering a User model by its full name when it's stored in two columns (name, lastName). Currently, the only way this is possible (AFAIK) is by sending the RAW query, which makes it almost incompatible with adding more filters.

Examples

Table example: id name lastName
1 Jackson Bell
2 Sarah Parker
3 Mason Brown

Example of one (possible) implementation of filter object:

{
  "limit": 10,
  "offset": 0,
  "where": {
    "leavingDate": null,
    "concat": {
      "eq": "%on B%",
      "separator": " ",
      "columns": [
        "name",
        "lastName"
      ]
    }
  }
}
Should return: id name lastName
1 Jackson Bell
3 Mason Brown

Acceptance criteria

TBD - will be filled by the team.

jannyHou commented 3 years ago

Thank you for the suggestion! This would be a big feature that involve changes in all the supported SQL/NoSQL connectors. First we need to agree on the signature, like you suggested using concat, then each connector builds the query accordingly.

achrinza commented 3 years ago

At a glance, I think the preceding feature we need to implement is referencing other values within the same model (e.g. Model.propA == Model.propB). From there, we can build on top of that feature to create more complex intra-model property comparators.

stale[bot] commented 3 years ago

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

Habbiton commented 2 years ago

Any news on this?

achrinza commented 2 years ago

@Habbiton This feature isn't being actively worked on at the moment.

A-Corregidor commented 1 year ago

Hi @achrinza ! It's been 2 years, any news? Is it scheduled to be resolved?