你可以看到我的文件如下。如何为我的 uniq 字段编写查找?
我需要搜索 KEYMAP 为 (SNUM="3151" and "SKEY"="THR" and "SID"="ID_HUT") 的文档
{
"CID":"2",
"DESCRIPTION":"test",
"SECKEY":"test",
"API":{
"SMS":"http://api.php",
"DR":"http://api2.php"
},
"LOGS":{
"IN":"log_cid_in_1",
"OUT": "log_cid_out_1"
},
"KEYMAP":[
{"SNUM":"3151","SKEY":"THR", "SID":"ID_HUT"},
{"SNUM":"3152","SKEY":"ONE", "SID":"ID_XL"},
{"SNUM":"3153","SKEY":"TWO", "SID":"ID_INDO"}
]
}
db.content_provider_map.ensureIndex({"KEYMAP.SNUM":1,"KEYMAP.SKEY":1,"KEYMAP.SID":1},{unique:true});
db.mycollection.find({"KEYMAP.SNUM":"3151","KEYMAP.SKEY":"TWO","KEYMAP.SID":"ID_XL"});# not work. it find the document