[英]How can I make in sails a query with a where clause and a 'or pairs' clause
I need to make a query in Sails that need to mix a where clause with a 'or pairs' clause. 我需要在Sails中进行查询,该查询需要将where子句与“ or pair”子句混合使用。 By example, the result must be all the records of an especified user (user: $scope.user.id) additionally from this records, only only those who field1 = cond1 OR field2 = cond2 ...
例如,结果必须是该记录中另外一个指定用户(用户:$ scope.user.id)的所有记录,只有那些field1 = cond1 OR field2 = cond2 ...
I'm using sails with MySQL. 我在MySQL中使用帆。 Thanks.
谢谢。
To get you started with OR queries: http://sailsjs.org/documentation/concepts/models-and-orm/query-language#?or-pairs 若要开始使用OR查询: http : //sailsjs.org/documentation/concepts/models-and-orm/query-language#?or-pairs
Model.find({
user_id: 'xy'
or : [
{ name: 'walter' },
{ occupation: 'teacher' }
]
})
This query will take all records containing user_id=xy and additionally filter those records with the OR query. 该查询将获取所有包含user_id = xy的记录,并使用OR查询过滤这些记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.