Mongodb group by on internal element

时间:2015-09-09 06:54:55

标签: mongodb

我有以下格式的数据

{
  _id:ObjectId("someid"),
  "masterKey":{
    "key1":"val1",
    "key2":"val2",
    "key3":"val3",
    "key4":"val1",
    "key5":"val2",
    "key6":"val3",
  }
}

我期待将主密钥的重复值分组的结果。

结果应与此类似。或者以任何其他格式查找具有键名的键的重复值。

{
  _id:Object("someid"),
  "masterKey":{
    "val1":["key1","key4"],
    "val2":["key2","key5"],
    "val3":["key3","key6"]
  }
}

0 个答案:

没有答案