loopback-next
loopback-next copied to clipboard
Filter by the concatenation of two columns
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.
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.
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.
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.
Any news on this?
@Habbiton This feature isn't being actively worked on at the moment.
Hi @achrinza ! It's been 2 years, any news? Is it scheduled to be resolved?