I'm trying a query on a postgres database through the loopback api explorer:
{"where": {"archived_at":{ "neq": null }}}
However, I only get results where archived_at is null?
I'm trying a query on a postgres database through the loopback api explorer:
{"where": {"archived_at":{ "neq": null }}}
However, I only get results where archived_at is null?
The following query worked for me...
{ "include": [ "currency" ], "where": { "currencyCode": { "neq": null } } }
I was requesting tables that had a currencyCode...
(Sorry for the poor quality of my response, I just wanted to share, even I didn't have a straight answer to the OG's question, and I don't have enough props to comment)
It depends on the database. Based on postgresql in loopback 3.
For search integer / number null or not null value.
I think it depends on the database and loopback version.
You can try like nlike
query in loopback (but how to use it depends on the db) https://loopback.io/doc/en/lb3/Where-filter.html#ilike-and-nilike
Querying not null value
Explorer:
{"where": {"principalId": { "neq": "" }} }
or in server
{where: {"principalId": { neq: "" }} }
Try to direct query in database. Loopback allowed for that.
"angular": "^1.6.3",
"angular-messages": "^1.6.3",
"angular-ui-validate": "^1.2.2",
"async": "^2.1.5",
"bower": "^1.8.0",
"compression": "^1.6.2",
"cors": "^2.8.1",
"helmet": "^3.5.0",
"loopback": "^3.7.0",
"loopback-boot": "^2.23.0",
"loopback-component-explorer": "^4.2.0",
"
loopback-component-storage": "^3.2.0",
"loopback-connector-mongodb": "^3.0.1",
"loopback-connector-mysql": "^3.0.0",
"loopback-connector-postgresql": "^2.8.0",
"loopback-console": "^1.1.0",
"loopback-datasource-juggler": "^3.5.0",
"loopback-sdk-angular-cli": "^3.0.0",
"milligram": "^1.3.0",
"serve-favicon": "^2.4.2",
"strong-error-handler": "^2.0.0"
You need to cast it as unknown
and then cast it back.
const filter = {...};
const whereSoftDeleted = <Condition<T>>(<unknown>{
archivedAt: {neq: null},
});
const newFilter = {
...filter,
where: {...filter.where, ...whereSoftDeleted},
});
© 2022 - 2024 — McMap. All rights reserved.
archived_at = NULL
then it won't work, since NULL is not equal to even NULL. – Rappernull
but not records where the field is non-null
(which is the opposite of what the query looks like it should give). I also get the same if I use{"where":{"archived_at":{}}}
. But{"where":{"archived_at":{"neq":{}}}}
gives me everything, unfiltered. I'd love to know the answer to this, surely getting all records with a non-null
value in a given field is a common use case. – Giule