外部結合なら $match の部分なしで結果がとれます。
_id で照らし合わせる場合、ObjectId(id) で合わせるか文字列へ変換するか気を付ける必要があります。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"_id":"5d355b602f3e9e3268f12a20","composer_id":"5d2b80272f3e9e25e0eadccf"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask_pymongo import PyMongo | |
classics = list(mongo.db.classics.aggregate( | |
[ | |
{ "$lookup" : | |
{ | |
"from":"baroque", | |
"localField":"composer_id", | |
"foreignField":"composer_id", | |
"as":"baroqueid" | |
} | |
} | |
, | |
{ "$match" : | |
{ | |
"baroqueid": {"$ne": []} | |
} | |
} | |
] | |
)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id":"5d2fdb532f3e9e25b046aed1", | |
"title":"01 Track 1.wma", | |
"path":"\\Music\\BACH.Johann.Sebastian\\Bach Brandenburg Concertos Nos. 1-4, 6\\01 Track 1.wma", | |
"composer":"BACH.Johann.Sebastian", | |
"work":"Bach Brandenburg Concertos Nos. 1-4, 6","composer_id":"5d2b80272f3e9e25e0eadccf" | |
} |