尝试在 findOne 和 Node api returns 空数组中执行 where 过滤器,当在环回中按 id 过滤时

Trying to do a where filter in findOne and in Node api returns empty array when filtering by ids in loopback

尝试在 findOne 和节点中执行 where 过滤器 api returns 在环回中按 ID 过滤时为空数组

https://url/api/Model1/findOne?filter={"where":{"attrs":"id"}} 其中 id 正好是 24 位数字

您可能在数据库的特定集合中没有具有该 ID 的对象。在这种情况下,您应该得到一个空数组。

或者您可能需要通过 id 而不是 attr 查找 - 这取决于数据库中相关字段的命名方式。

查看文档,那里有很好的例子:https://loopback.io/doc/en/lb2/Where-filter.html

例如这个:

http://localhost:3000/api/Books?filter={"where":{"or":[{"id":1},{"id":2}]}}

请注意,使用的是 id 而不是 attr。看看你的领域是什么。