I have lets say 2 collections , profile and followers . Profiles contain some ..profile informations (characteristics , photo id, etc..) and followers contain the profile _ID reference of followed . I attached the sample of this 2 collection bellow . We see in followers collection the last followers of bob(_id 1) are 4,2,3 respectively prince,jhon , alice . The _id 3 is alice and this is the last inserted .
I need to display all profiles informations(contain in profile collection) of each last followers of bob in the logical order " new before older " . I guess it need 2 querys but even that i didn't find solution / feature to do that , is it possible ? If you know if not possible in 2 querys , i am totatly open for others patterns advises .
For the example given above , the result expected (note the order is 3 , 2 , 4)should be :
{
"_id" : 3,
"name" : "alice",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 7800098
}
{
"_id" : 2,
"name" : "jhon",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 7111987
}
{
"_id" : 4,
"name" : "prince",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 6535098
}
the profile collection sample :
db.profile.find()
{
"_id" : 1,
"name" : "bob",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 7863635
}
{
"_id" : 2,
"name" : "jhon",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 7111987
}
{
"_id" : 3,
"name" : "alice",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 7800098
}
{
"_id" : 4,
"name" : "prince",
"Region1" : "Alsace",
"code_postal" : 67240,
"ville" : "Oberhoffen-sur-Moder",
"photo_id" : 6535098
}
followers collection sample :
db.followers.find()
{
"_id" : 1,
"followers" : [4,2,3]
}
{
"_id" : 2,
"followers" : [8,2,3,11,39,653,]
}
{
"_id" : 3,
"followers" : [9,76,538,111,134]
}