I have this collection "user" :
[{
"_id": {
"$oid": "5f7b21afd3ad8808032490de"
},
"role": "admin",
"email": "[email protected]",
"username": "Test",
"status": "active",
"following": [
{
"$oid": "5fc767b09ae62d40ba09624f"
}
],
},{
"_id": {
"$oid": "5fc767b09ae62d40ba09624f"
},
"role": "streamer",
"email": "[email protected]",
"username": "Test_2",
"status": "active",
"following": []
}]
I am trying to get the follower of each user, this is what I've began but the followers
is empty array :
{
$lookup: {
from: 'user',
let: { userId: '$_id'},
pipeline: [
{
$match: {
following: {
$all: ['$$userId']
}
}
}
],
as: 'followers'
}
}
Do you know what's wrong in my code ?
Thank you
question from:
https://stackoverflow.com/questions/66051587/cannot-get-documents-with-an-all-in-pipeline-lookup 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…