I am very new to MongoDB. However for the last 48 hours I managed to create a nice collection of Amazon products, mostly audio CDs and DVDs. The Products collection has approximately 50k documents in the following format:
[{
"_id": {
"$oid": "5fbc2e9b8ca9b50a6c13fc56"
},
"016581598027": [
{
"ASIN": "B00008OM5J",
"Language": "en-US",
"AudienceRating": "NR (Not Rated)",
"Binding": "Audio CD",
"Creator": "Nothingface",
"Edition": "Parental Advisory ed.",
"Label": "TVT",
}
]
}]
When I query Amazon MWS my program automatically saves query results to MongoDB.
The 016581598027
is a UPC (Universal Product Code) which may be referred to as a product identifier. Needless to say that each document in my collection is supposed to have a different UPC at this nest level. However I want to be able to query and find a document on a specific ASIN
. As a pseudo-code what I want is this:
mydb.Products.find({"ASIN":"B00008OM5J"})
So after the above query fires I must have a reference to a sole document. How do I do that? I’ve tried everything – RTFM, talked to Julia bot, etc. but nothing helps.
To make it even more interesting for you, I’d like to extend the previous task with an OR query:
document = (mydb.Products.find({"ASIN":"B00008OM5J"}) OR mydb.Products.find("????":"016581598027"))
How do I implement this?
Thanks
Mark