我有expertKstag件藏品
{
_id: ObjectId('6244213ec4c8aa000104d5ba'),
userID: '60a65e6142e3320001cc8178',
uid: 'klavidal',
firstName: 'Kevin',
name: 'Lavidal',
email: 'kevin.lavidal@xxx.fr',
expertProfileInProgressList: {},
expertProfileList: [
{
_id: ObjectId('6453abc94e5cd20001596e1c'),
version: 0,
language: 'fr',
isReference: true,
state: 'PUBLISHED',
personalDetails: {
firstName: 'Kevin',
name: 'Lavidal',
email: 'kevin.lavidal@xxx.fr',
isAbesIDFromLdap: false,
requiredFieldsLeft: false
},
professionalStatus: {
corpsID: '62442223b8fb982305a5bd67',
lastUpdateDate: ISODate('2023-05-05T08:36:51.327Z')
}
],
_class: 'fr.ubordeaux.thehub.expertprofilesservice.model.dao.indexed.ExpertIndexed'
}
和集合nomenclatureKstag
{
_id: ObjectId('62442223b8fb982305a5bd67'),
type: 'STATUT_CORPS',
level: 1,
hasCNU: true,
labels: [
{
language: 'fr',
text: 'Enseignant-chercheur'
},
{
language: 'en',
text: 'Teacher-Researcher'
}
],
isValid: true
}
我想加入expertKstag-&>expertProfileList.professionalStatus.corpsID
和nomenclatureKstag-->_id
我试过了,但什么也没有退回,为什么?
db.expertKstag.aggregate([
{
$lookup:
{
from: "nomenclatureKstag",
localField: "expertKstag.expertProfileList.professionalStatus.corpsID",
foreignField: "_id",
as: "joinresultat"
}
},
{
$unwind: "$join_resultat"
},
{
$project: {
"_id": 1,
"userID": 1,
"uid": 1,
"firstName": 1,
"name": 1,
"email": 1,
"join_resultat.isValid": 1
}
}
])
谢谢你的帮助,我认为问题是JOIN _id
是ObjectId
类型,而expertKstag.expertProfileList.professionalStatus.corpsID
不是.