Node.js 如何使用;“查找位置”;航行路线图? 用例

Node.js 如何使用;“查找位置”;航行路线图? 用例,node.js,mongoose,sails.js,waterline,Node.js,Mongoose,Sails.js,Waterline,我想使用SailsJS“”蓝图路线创建一个包含多个条件的复杂查询。但是,我无法成功使用equals比较器和and条件。我找不到关于如何实现find-Where路由的足够文档,所以我通过研究,提出了以下场景 问题: 使用SailsJS查找何处蓝图路线,如何实现: 平等比较 环境与条件 成功情景 以下场景将返回相应的响应: http://localhost:1337/api/user?name=fred http://localhost:1337/api/user?where={"name":{

我想使用SailsJS“”蓝图路线创建一个包含多个条件的复杂查询。但是,我无法成功使用equals比较器和and条件。我找不到关于如何实现find-Where路由的足够文档,所以我通过研究,提出了以下场景

问题: 使用SailsJS查找何处蓝图路线,如何实现:

  • 平等比较
  • 环境与条件
成功情景 以下场景将返回相应的响应:

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"}}]}
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"}}]}
故障场景 以下场景返回空响应:

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"}}]}
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"}}]}
要使用“和”查询,请使用查询字符串语法,并使用符号和字符将条件链接在一起。对于更高级的查询,如
或复杂运算符,最好编写一个控制器操作。如果您决定坚持使用蓝图,您可以使用编码为JSON的最有效的水线查询

对于简单查询,可以使用查询字符串方法。下面将构建一个名称和学校的“and”查询

http://localhost:1337/api/user?name=fred&school=foo
要将更高级的运营商联系在一起,应采取以下措施:

http://localhost:1337/api/user?where={"name":{"startsWith":"fred"},"path":{"endsWith":"fred"}}

仅供参考:如果您试图搜索日期值,则有一个打开的。