I have various GET http calls to my api with the following format:
/api/posts?userId=3
However, it is not filtering posts by its userId
column, and just returns all posts, regardless of the posts' userId.
This syntax has worked in past projects I've had also, and is documented here. (The example they give is GET /purchase?amount=99.99
).
Questions I've seen do not address the query language via defaults routes in this way, so I'm having trouble finding help. Any guesses on what could be going wrong?
UPDATE:
What does work as expected
req.query
is getting set and read by policies (eg, ?userId=3
is found by req.param("userId")
)/api/posts?userId=3&populate=userId
populates the userId
field, (but still returns all posts for all users)?id=5
) filters and returns only one record as expectedPosts.find({userId: 3})
) works What does not work as expected
?userId=6
)?name=test
)where
(eg &where={"userId":1}
)答案 0 :(得分:0)
事实证明,我正在为策略中的每个查询添加“where”子句(例如,"where: {"status": "active"}}
)。查询字符串中的“where”会自动overrides the other params,因此没有其他内容可见。 (确切地说,如果你有where子句,其他标准永远不会被看到)
出于某种原因,“where”也无法设置帆的搜索条件0.12.13,所以我最终在风帆中攻击parseCriteria
函数actionUtils并使用它们为第1节而且对我有用。
希望将来帮助任何人