为不匹配的元素创建 Mango 查询选择器

Creating a Mango query selector for element that do NOT match

我有一个这样的用户:

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

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

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

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

找到答案。这最终奏效了:

{ training: { $not: {$elemMatch: {id: "11111" } } }