Usage example
I would like to create a complex query with more than one criterion using the SailsJS Find Where "route plan. However, I cannot use the equals compator as well as the condition successfully. I could not find adequate documentation on how to implement the Find route Where, so I worked through the source code and came up with the following scripts.
Question
Using SailsJS Find Where Blueprint Route, how to implement this:
- equality comparison
- and condition
Success scenarios
The following scripts will return the appropriate response:
http://localhost:1337/api/user?name=fred http://localhost:1337/api/user?where={"name":{"startsWith":"fred"}} http://localhost:1337/api/user?where={"name":{"endsWith":"fred"}} http://localhost:1337/api/user?where={"name":{"contains":"fred"}} http://localhost:1337/api/user?where={"name":{"like":"fred"}} http://localhost:1337/api/user?where={"or":[{"name":{"startsWith":"fred"}}]} http://localhost:1337/api/user?where={"or":[{"name":{"startsWith":"fred"}},{"path":{"endsWith":"fred"}}]}
Failure Scenario
The following scripts return an empty response:
http://localhost:1337/api/user?where={"name":{"equals":"fred"}} http://localhost:1337/api/user?where={"name":{"=":"fred"}} http://localhost:1337/api/user?where={"name":{"equal":"fred"}} http://localhost:1337/api/user?where={"and":[{"name":{"startsWith":"fred"}}]} http://localhost:1337/api/user?where={"and":[{"name":{"startsWith":"fred"}},{"path":{"endsWith":"fred"}}]}
source share