i am newbie in Mongodb and i want to create query with sibling keys but i'm unable. Let's clear with example:-
Here is my mongodb document:-
{
userId:1,
name:'abc',
game:{
gener:'puzzle',
gId:4
gRid:12,
mTepCount:890,
pT:'high',
related:[{
gRid:14,
name:'xyz',
count:230
},{
gRid:12,
name:'yzdd',
count:300
}]
}
}
I have written query like this, but not working,
db.test.aggregate([{
$match:{
'game.gRid':'game.related.gRid'
}
}])
In Sql, the query will be like ,
1) SELECT a.name,b.count from a INNER JOIN b ON a.gRid=b.gRid WHERE pT='high'