0
0条评论

db.compounds.aggregate([
{
$lookup:
{
from:”massSpectrum”,//关联表massSpectrum
localField:”_id”,//compounds表中要关联的字段
foreignField:”compdId”,//massSpectrum表中要关联的字段
as:”spectra”
}
},
{
$match:
{
“_id”:ObjectId(“5f631b412fde8f1d30df982e”),
}
},
{
$project:
{
_id:1,code:1,cname:1,ename:1,structure:1,molecule:1,weight:1,mass:1,smiles:1,pubchemCid:1,
‘spectra._id’:1,’spectra.level’:1,’spectra.mz’:1,’spectra.intensity’:1,’spectra.source’:1,

//问题:下面的语句把内嵌文档重命名之后,instrument这些字段的字段类型变成了array,怎样保持原有的数据类型?
“spectra.experiment.instrument”:”$spectra.instrument”,’spectra.experiment.instrumentType’:”$spectra.instrumentType”,
“spectra.experiment.ionMode”:”$spectra.ionMode”,’spectra.experiment.collEnergy’:”$spectra.collEnergy”
}
}
])

//结果截取显示

“experiment” : {
“instrument” : [
“Bruker maXis Impact”
],
“instrumentType” : [
“LC-ESI-QTOF”
],
“ionMode” : [
“positive”
],
“collEnergy” : [
“Ramp 21.1-31.6 eV”
]
}

非常感谢!

更改状态以发布