Use Case
I'd like to create a complex query with more than one criterion using the SailsJS "Find Where" blueprint route. However, I am unable to use the equals comparator and the and condition successfully. I couldn't find adequate documentation on how to implement the Find Where route, so I worked through the source code and came up with the following scenarios.
Question
Using the SailsJS Find Where Blueprint Route, how does one implement:
- the equality comparison
- the and condition
Success Scenarios
The following scenarios 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 scenarios 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"}}]}