vaje: Še namig za agregcijo podatkov (unwind ...)
Completion requirements
rez=mongoDB.naslov.aggregate([{
rez=mongoDB.naslov.aggregate([{
"$lookup" : {
"from" : "pacient",
"localField" : "naslovID",
"foreignField" : "naslovID",
"as" : "pacient"
}
},{
"$unwind" : {
"path" : "$pacient"
}
},{
"$lookup" : {
"from" : "kraj",
"localField" : "posta",
"foreignField" : "posta",
"as" : "kraj"
}
},{
"$unwind" : {
"path" : "$kraj"
}
}
])
for doc in rez :
print(f"\
{doc['pacient']['ime']\t\
{doc['pacient']['priimek']\t\
{doc['ulica']\t\
{doc['hisnastevilka']\t\
{doc['kraj']['posta']\t\
{doc['kraj']['kraj']}"
)
Click on vaje: Še namig za agregcijo podatkov (unwind ...) to open the resource.