我正在尝试编写一个mongo查询来返回与cat1和cat2源完全相同的电子邮件的文档。
请帮忙。我包含一个带有预期匹配文档的样本集合模式
样品采集
{
"id" : "1",
"name" : "John",
"contacts" : [
{
"type" : "email",
"source": "cat1",
"detail": aa@yahoo.com
},
{
"type" : "email",
"source": "cat1",
"detail": john@yahoo.com
},
{
"type" : "email",
"source": "cat2",
"detail": john@yahoo.com
}
]
},
{
"id" : "2",
"name" : "Bell",
"contacts" : [
{
"type" : "email",
"source": "cat1",
"detail": jj@yahoo.com
},
{
"type" : "email",
"source": "cat2",
"detail": john@yahoo.com
}
]
},
{
"id" : "3",
"name" : "Sam",
"contacts" : [
{
"type" : "email",
"source": "cat1",
"detail": exmaple@yahoo.com
},
{
"type" : "email",
"source": "cat3",
"detail": exmaple@yahoo.com
}
]
}
预期结果如下:因为这是来自源cat1和cat2的公共电子邮件地址为john@yahoo.com的文档。
不应返回ID为2的文档,因为虽然它们都有来自cat1和cat2源的电子邮件,但电子邮件地址却不同。
不应返回ID为3的文档,因为通过电子邮件地址相同,其类别不是cat1和cat2。
{
"id" : "1",
"name" : "John",
"contacts" : [
{
"type" : "email",
"source": "cat1",
"detail": aa@yahoo.com
},
{
"type" : "email",
"source": "cat1",
"detail": john@yahoo.com
},
{
"type" : "email",
"source": "cat2",
"detail": john@yahoo.com
}
]
}
答案 0 :(得分:0)
请尝试使用纯JavaScript代码过滤来自cat1和cat2的同一封电子邮件。
public class gameWindow extends JFrame {
public gameWindow() {
add(new SashaOhayonSnakeFST());
setResizable(false);
pack();
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() { //Creates queue to run events
public void run() { //runs these events on new window
JFrame finalWindow = new gameWindow();
finalWindow.setVisible(true);
finalWindow.setBackground(new Color (0,0,0,0));
}
});
}
}