问题
我无法更改 curl
调用中的默认 AND
运算符,如 directus api 文档中所述:
https://docs.directus.io/api/reference.html#filtering
问题
如何启用 OR
运算符以便根据不同的条件进行过滤,如下面的代码?
代码
return client
.getItems('privileges', {
fields: ['*', 'image.filename', 'image.data.full_url', 'attachment.*', 'partner.*.*', 'location.*', 'category.*.*', 'type.icon.data.full_url'],
meta: ['total_count', 'result_count'],
sort: 'created_on',
filter: {
'location.city': {
'contains': lowerQ
},
// 'location.title': {
// 'contains': lowerQ
// },
category: {
'eq': category,
},
available_from: {
'lte': 'now'
},
available_until: {
'gte': 'now'
},
},
limit,
offset,
}).then(response => {
dispatch(getPrivilegesSuccess(key, response))
}).catch(error => {
console.log(error);
dispatch(getPrivilegesFail(key, error))
});
So, the comments out code is a different criteria that should be able to match on inserted text using the or operator. Instead it is using the AND operator in the curl output api call at the moment.
非常感谢任何类型的帮助!
最佳答案
filter: {
field_one: {
'eq': 'hello'
},
field_two: {
'logical': 'or',
'eq': 'world'
},
},
只需将 'logic': 'or'
添加到您想要用作“OR”的对象
关于javascript - 如何使用 Directus Javascript SDK 进行条件过滤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57867151/