Being a novice in the realm of mongodb, I welcome any corrections if my terminology is incorrect:
The document snippet below showcases some information:
{
"_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
]
}
]
}
Upon executing
db.substances.findOne({name: "Irbesartan"}).precursor
The following data is retrieved:
[
{
"mass" : 429,
"ion" : "+H",
"charge" : "+",
"fragments" : [
207,
195,
180
]
},
{
"mass" : 427.2252,
"ion" : "-H",
"charge" : "-",
"fragments" : [
193,
399
]
}
]
I am interested in accessing the fields within, particularly the fragment array (using Mongo Shell)
Is achieving this in a single query possible?
Or would it be more advantageous to store the precursor as an array rather than a subdocument?