i am new to mongodb so please correct me if i am using the wrong terms:
I have the following document(excerpt)
{
"_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
]
}
]
}
With
db.substances.findOne({name: "Irbesartan"}).precursor
i get the following
[
{
"mass" : 429,
"ion" : "+H",
"charge" : "+",
"fragments" : [
207,
195,
180
]
},
{
"mass" : 427.2252,
"ion" : "-H",
"charge" : "-",
"fragments" : [
193,
399
]
}
]
But i want to acces the fields inside, espacially the fragment array (using Mongo Shell)
Is this possible in one query?
Or is it better to store the precursor as an array instead of a subdocument?