问题

我无法像在directus api docs中解释的那样在AND调用中更改默认的curl运算符:

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))
  });



  因此,注释掉代码是一个不同的条件,应该可以使用or运算符对插入的文本进行匹配。相反,它现在在curl输出api调用中使用AND运算符。


将不胜感激任何类型的帮助!

最佳答案

filter: {
  field_one: {
    'eq': 'hello'
  },
  field_two: {
    'logical': 'or',
    'eq': 'world'
  },
},


只需将'logical': 'or'添加到要用作“或”的对象

09-16 19:37