Hi,
I don’t understand the exercise. What should I count on?
I tried with the following code, but it doesn’t work.
db.movies.aggregate([
{ $match: { writers: { $elemMatch: { $exists: true } } }},
{ $project:{
_id: 0, writers: {
$map: {
input: “$writers”,
as: “writer”,
in: { $arrayElemAt: [ { $split: [ “$$writer”, " (" ] }, 0 ] }
}
}, “cw”: {$setIntersection: ["$cast", “$writers”]}, directors: 1
}
},
{ $match: {cw: {$size: {$gt: 0}}, cw: {$ne: null} }},
{ $project:{
_id: 0, “cwd”: {$setIntersection: ["$cw", “$directors”]}, directors: 1
}
},
{ $match: {cwd: {$size: {$gt: 0}}, cwd: {$ne: null} }},
])
You can help me
I don’t understand where error is?