N1QL数组查询检查内部条件的条件

时间:2016-11-25 08:46:44

标签: json node.js couchbase n1ql

我有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中做到?

2 个答案:

答案 0 :(得分:2)

试试这个:

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

保留此cheatsheet

答案 1 :(得分:2)

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

我得到了这个答案