Trying to do a where filter in findOne and in Node api returns empty array when filtering by ids in loopback
https://url/api/Model1/findOne?filter={"where":{"attrs":"id"}}
where id is exactly 24 digits long
It is possible that you simple don't have an object with that ID in that particular collection in the database. In such a case you should get an empty array.
Or you may need to find by id
and not by attr
- it depends on how the relevant field in your database is named.
See the docs, there are good examples there: https://loopback.io/doc/en/lb2/Where-filter.html
E.g. this:
http://localhost:3000/api/Books?filter={"where":{"or":[{"id":1},{"id":2}]}}
Note that the id
is used and not attr
. See what is your field in your case.