Open dzuluaga opened 8 years ago
I've just found the solution. Instead of using contain, which is the notation from Waterline. You need to stick to sequelize notation. Therefore, the search above should be translated into:
curl -G -X GET 'http://localhost:1337/user' --data-urlencode 'where={"name":{"$like":"%Eri%"}}' -v
Interesting, it's related to the waterline / sequelize notation or something with this hook? i haven't tested with the where
criteria object, only with http://localhost:1337/user?name=value&age=21
,
thanks for the feedback.
Correct, my confusion was that I was reading Sails.js Blueprint and I was using the exact Waterline notation to run "like" queries, and the response from the server wasn't helping to troubleshoot the issue. After I looked into the code in this line, I realized that it used sequelize model, which uses a sligthly different convention than waterline. I wonder that more users may have run into this issue and this could save them some time of debugging.
Thanks @dzuluaga, it works by using sequelize combinations. By the way, the query string should be encoded like --data-urlencode
, such as http://localhost:1337/user?where={"$or":[{"name":{"$like":"hello%25"}},{"id":2}]}
, where %25
denotes to %
, otherwise the where condition should not work.
Great hook. Pretty much everything worked except for find where clause. For instance, I tried to run the following API request and it returned a strage error:
Error:
Am I doing anything wrong? Thanks!