N1QL 数组查询 where 条件以检查内部元素

N1QL Array Query for where condition to check inner elament

我有 JSON 如下所示

{
  "_id": "000fad10-b2de-11e6-92de-632a9b1d21d9",
  "_type": "Company",
  "status": 1,
  "transactions": [
    {
      "completed": 1,
      "currency": "USD",
      "date": "2015-12-01T18:30:00.000Z",
      "method": 0,
      "type": 0
    }
  ]
}

我想运行喜欢下面的查询

select * from MyBucket where transactions.method in (0,3);

我怎样才能在 N1QL 中做到这一点??

试试这个:

SELECT * FROM MyBucket b UNNEST b.transactions t WHERE t.method in [0,3];

保持这个cheatsheet

SELECT * FROM MyBucket WHERE ANY x IN transactions SATISFIES x.method in[1,0] END;

我通过这个得到答案