In many lectures I cannot say whether it is possible to execute this equivalent sql query in 1 question using mongo:
SELECT * from collection WHERE _id NOT IN (SELECT blacklist from collection WHERE _id = 1 )
I tried a lot of things with aggregatio but could not work.
Here is my collection:
{
"_id" : 1,
"blacklist" : [8,9,10,3]
"code_postal" : 67110,
"loc" : {
"type" : "Point",
"coordinates" : [
7.72,
48.91
]
}
}
{
"_id" : 2,
"blacklist" : [18,1,93]
"code_postal" : 67110,
"loc" : {
"type" : "Point",
"coordinates" : [
7.63,
48.91
]
}
}
{
"_id" : 3,
"blacklist" : [7,3]
"code_postal" : 67110,
"loc" : {
"type" : "Point",
"coordinates" : [
7.7,
48.96
]
}
}
The result expected with this request and this collection should be (_id 3 is excluded, since _id 1 is in the blacklist):
{
"_id" : 1,
"blacklist" : [8,9,10,3]
"code_postal" : 67110,
"loc" : {
"type" : "Point",
"coordinates" : [
7.72,
48.91
]
}
}
{
"_id" : 2,
"blacklist" : [18,1,93]
"code_postal" : 67110,
"loc" : {
"type" : "Point",
"coordinates" : [
7.63,
48.91
]
}
}
considers