1

我有一个这样的用户:

{
  "_id": "u88888",
  "_rev": "27-9f205fb7496645be2f3d717fff376d73",
  "name": "Test Testerson",
  "type": "user",
  "role": "boss",
  "training": [
    {
      "id": "11111",
       "name": "training 1"
    },
    {
      "id": "33333",
      "name": "training 3"
    }
  ]
}

我正在尝试运行查询以查找以下内容:

  • 是一种类型,“用户”
  • 有“老板”的角色
  • 没有id的训练:“11111

我做了以下选择器,但是,这个用户出现了,我不知道为什么:

selector:{
    "$and": [
        { "type": "user" },
        { "role": "boss" },
        { "training": { "$ne": { "id": "11111" } } }
    ]
}
4

1 回答 1

3

找到了答案。这最终起作用了:

{ training: { $not: {$elemMatch: {id: "11111" } } }
于 2018-06-18T18:45:10.893 回答