在WHERE过滤器上使用OR条件查找StrongLoop Loopback模型 [英] StrongLoop Loopback Model find with OR condition on WHERE filter
问题描述
我试图通过使用StrongLoop的Model.find语法的名称或标识符来找到一个人(文档在这里: http://apidocs.strongloop.com/loopback/#modelfindfilter-callback )。
但我无法弄清楚指定OR条件。
我可以使用以下语法匹配名称和标识符:
$ pre > person.find({
其中:{
'name.text':{like:'Dave'},
'identifier.value':{like: '3303927'}
}
},callback);
但是我希望能够匹配名字OR标识符,像这样:
person.find({
其中:{
'name.text':{like:'Dave'} ||
'identifier.value':{like:'3303927'}
}
},callback);
这个不支持,或者我无法得到正确的语法。看来这是通过REST API支持的(doc: http:/ / /docs.strongloop.com/display/DOC/Model+REST+API#ModelRESTAPI-Findmatchinginstances ),所以我希望这是我试图完成它的方式支持。
谢谢!
最近添加了AND / OR运算符。请参阅使用示例:
person.find({
其中:{
或:{
'name.text':{like:'Dave'},
'identifier.value':{like:'3303927'}
}
}
},回调);
I'm trying to find a person by either their name OR identifier using StrongLoop's Model.find syntax (documentation here: http://apidocs.strongloop.com/loopback/#modelfindfilter-callback).
But I can't figure out how to specify the OR condition.
I can match both the name AND identifier using this syntax:
person.find({
where: {
'name.text': {like: 'Dave'},
'identifier.value': {like: '3303927'}
}
}, callback);
But I'd like to be able to match name OR identifier doing something like this:
person.find({
where: {
'name.text': {like: 'Dave'} ||
'identifier.value': {like: '3303927'}
}
}, callback);
Either this isn't supported or I can't get the syntax correct. It appears this is supported via the REST API (doc: http://docs.strongloop.com/display/DOC/Model+REST+API#ModelRESTAPI-Findmatchinginstances) so I'm hoping it's supported the way I'm trying to accomplish it.
Thanks!
The AND/OR operator is added recently. Please see examples of usage at:
The syntax is:
person.find({
where: {
or: {
'name.text': {like: 'Dave'},
'identifier.value': {like: '3303927'}
}
}
}, callback);
这篇关于在WHERE过滤器上使用OR条件查找StrongLoop Loopback模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!