我是 mongodb 的新手,所以如果我使用了错误的术语,请纠正我:
我有以下文件(摘录)
{
"_id" : ObjectId("524b0a1a7294ec8a39d4230f"),
"name" : "Irbesartan",
"decompositions" : [
"IRB_444",
"IRB_442",
"IRB_446",
"Valsartan acid"
],
"precursor" : [
{
"mass" : 429,
"ion" : "+H",
"charge" : "+",
"fragments" : [
207,
195,
180
]
},
{
"mass" : 427.2252,
"ion" : "-H",
"charge" : "-",
"fragments" : [
193,
399
]
}
]
}
和
db.substances.findOne({name: "Irbesartan"}).precursor
我得到以下
[
{
"mass" : 429,
"ion" : "+H",
"charge" : "+",
"fragments" : [
207,
195,
180
]
},
{
"mass" : 427.2252,
"ion" : "-H",
"charge" : "-",
"fragments" : [
193,
399
]
}
]
但我想访问里面的字段,尤其是片段数组(使用 Mongo Shell)
这可能在一个查询中吗?
还是将前体存储为数组而不是子文档更好?